이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 1. Using Kustomize manifests to deploy applications


You can use the kustomize configuration management tool with application manifests to deploy applications. Read through the following procedures for an example of how Kustomize works in MicroShift.

1.1. How Kustomize works with manifests to deploy applications

The kustomize configuration management tool is integrated with MicroShift. You can use Kustomize and the OpenShift CLI (oc) together to apply customizations to your application manifests and deploy those applications to a MicroShift cluster.

  • A kustomization.yaml file is a specification of resources plus customizations.
  • Kustomize uses a kustomization.yaml file to load a resource, such as an application, then applies any changes you want to that application manifest and produces a copy of the manifest with the changes overlaid.
  • Using a manifest copy with an overlay keeps the original configuration file for your application intact, while enabling you to deploy iterations and customizations of your applications efficiently.
  • You can then deploy the application in your MicroShift cluster with an oc command.

1.1.1. How MicroShift uses manifests

At every start, MicroShift searches the following manifest directories for Kustomize manifest files:

  • /etc/microshift/manifests
  • /etc/microshift/manifests.d/*
  • /usr/lib/microshift/
  • /usr/lib/microshift/manifests.d/*

MicroShift automatically runs the equivalent of the kubectl apply -k command to apply the manifests to the cluster if any of the following file types exists in the searched directories:

  • kustomization.yaml
  • kustomization.yml
  • Kustomization

This automatic loading from multiple directories means you can manage MicroShift workloads with the flexibility of having different workloads run independently of each other.

Table 1.1. MicroShift manifest directories
LocationIntent

/etc/microshift/manifests

Read-write location for configuration management systems or development.

/etc/microshift/manifests.d/*

Read-write location for configuration management systems or development.

/usr/lib/microshift/manifests

Read-only location for embedding configuration manifests on OSTree-based systems.

/usr/lib/microshift/manifestsd./*

Read-only location for embedding configuration manifests on OSTree-based systems.

1.2. Override the list of manifest paths

You can override the list of default manifest paths by using a new single path, or by using a new glob pattern for multiple files. Use the following procedure to customize your manifest paths.

Procedure

  1. Override the list of default paths by inserting your own values and running one of the following commands:

    1. Set manifests.kustomizePaths to <"/opt/alternate/path"> in the configuration file for a single path.
    2. Set kustomizePaths to ,"/opt/alternative/path.d/*". in the configuration file for a glob pattern.

      manifests:
          kustomizePaths:
              - <location> 1
      1
      Set each location entry to an exact path by using "/opt/alternate/path" or a glob pattern by using "/opt/alternative/path.d/*".
  2. To disable loading manifests, set the configuration option to an empty list.

    manifests:
        kustomizePaths: []
    Note

    The configuration file overrides the defaults entirely. If the kustomizePaths value is set, only the values in the configuration file are used. Setting the value to an empty list disables manifest loading.

1.3. Using manifests example

This example demonstrates automatic deployment of a BusyBox container using kustomize manifests in the /etc/microshift/manifests directory.

Procedure

  1. Create the BusyBox manifest files by running the following commands:

    1. Define the directory location:

      $ MANIFEST_DIR=/etc/microshift/manifests
    2. Make the directory:

      $ sudo mkdir -p ${MANIFEST_DIR}
    3. Place the YAML file in the directory:

      sudo tee ${MANIFEST_DIR}/busybox.yaml &>/dev/null <<EOF
      apiVersion: v1
      kind: Namespace
      metadata:
        name: busybox
      ---
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: busybox
        namespace: busybox-deployment
      spec:
        selector:
          matchLabels:
            app: busybox
        template:
          metadata:
            labels:
              app: busybox
          spec:
            containers:
            - name: busybox
              image: BUSYBOX_IMAGE
              command: [ "/bin/sh", "-c", "while true ; do date; sleep 3600; done;" ]
      EOF
  2. Next, create the kustomize manifest files by running the following commands:

    1. Place the YAML file in the directory:

      sudo tee ${MANIFEST_DIR}/kustomization.yaml &>/dev/null <<EOF
      apiVersion: kustomize.config.k8s.io/v1beta1
      kind: Kustomization
      namespace: busybox
      resources:
        - busybox.yaml
      images:
        - name: BUSYBOX_IMAGE
          newName: busybox:1.35
      EOF
  3. Restart MicroShift to apply the manifests by running the following command:

    $ sudo systemctl restart microshift
  4. Apply the manifests and start the busybox pod by running the following command:

    $ oc get pods -n busybox
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.