Tanzu 패키지 관리

이 문서에서는 Tanzu Community Edition에서 서버 측 및 클라이언트 측 패키지의 관리에 대해 설명합니다. 이것은 우리의 패키지 관리가 구현되고 향상됨에 따라 시간이 지남에 따라 발전하게 될 실무 디자인 문서입니다.

서버 측

이 섹션에서는 익스텐션(extension)의 서버 측 관리에 대해 설명합니다. 특히 kapp-controller 및 관련 Packing API에 초점을 맞춥니다.

개요 및 API

Tanzu Community Edition은 Carvel Packaging API를 사용한 패키지 관리를 제공합니다. 기본 API는 다음과 같습니다.

  • Package: 패키지에 대한 메타데이터와 이를 충족하는 OCI 번들을 포함합니다. 일반적으로 참조되는 OCI 번들은 imgpkg 구성의 번들입니다. 패키지가 결국 PackageRepository에 번들로 제공됩니다.
  • PackageRepository: 패키지 번들입니다. 번들은 imgpkg를 사용하여 생성되고 OCI 리포지토리에 푸시됩니다. 캅 컨트롤러는 개체를 감시하고 클러스터에서 패키지를 사용할 수 있도록 합니다.
  • IntalledPackage: 클러스터에서 패키지를 설치하려고 합니다. tanzu 또는 kubectl CLI와 같은 클라이언트측 도구에 의해 적용됩니다. InstalledPackage는 패키지를 참조합니다.

패키지 생성

패키지는 PackageRepository의 내용을 기반으로 kapp 컨트롤러에 의해 생성됩니다. PackageRepository는 패키지 매니페스트의 OCI 번들을 가리킵니다. PackageRepository를 클러스터에 포함하면 기본적으로 Package를 사용할 수 있습니다. 이것은 다음과 같이 시각적으로 표현될 수 있습니다.

위와 같이 하면 사용자는 kubectl을 사용하여 모든 패키지를 볼 수 있습니다.

$ kubectl get packages
NAME                              PUBLIC-NAME            VERSION      AGE
pkg.test.carvel.dev.1.0.0         pkg.test.carvel.dev   1.0.0        7s
pkg.test.carvel.dev.2.0.0         pkg.test.carvel.dev   2.0.0        7s
pkg.test.carvel.dev.3.0.0-rc.1    pkg.test.carvel.dev   3.0.0-rc.1   7s

패키지 설치(서버 측)

Package를 설치하려면 InstalledPackage 리소스가 클러스터에 적용됩니다. 그러면 kapp-controller가 해당 Package 매니페스트에서 참조되는 구성 번들을 조회하도록 지시합니다. 그런 다음 이러한 자산을 다운로드하고 렌더링한 다음(예: ytt) 클러스터에 적용합니다. 이것은 다음과 같이 시각적으로 표현될 수 있습니다.

클라이언트 측면

이 섹션에서는 확장의 클라이언트 측 관리에 대해 설명합니다. 특히 패키지를 검색, 구성, 배포 및 관리하기 위해 tanzu CLI를 사용하는 것을 중점적으로 다룹니다.

패키지 검색

tanzu CLI는 클러스터에 알려진 패키지를 검색할 수 있습니다. 클러스터에서 사용할 수 있는 모든 Package CRs를 확인하여 이러한 패키지를 검색합니다. 이러한 패키지는 하나 이상의 PackageRepository CR에서 가져올 수 있습니다. 이 모델은 리포지토리(예: /etc/apt/sources.list)를 포함하면 관리자가 새 패키지를 사용할 수 있는 인기 Linux 패키지 관리자(예: apt)에서 영감을 받았습니다. 이것으로 다음과 같은 명령이 가능합니다.

tanzu package available list
| Retrieving available packages...
  NAME                                           DISPLAY-NAME        SHORT-DESCRIPTION
  cert-manager.community.tanzu.vmware.com        cert-manager        Certificate management
  contour-operator.community.tanzu.vmware.com    contour-operator    Layer 7 Ingress

위에서 tanzu CLI는 이미 존재하는 객체의 메타데이터를 집계하고 나열합니다. 각 패키지 인스턴스에서 다음을 수행합니다.

  • NAMEspec.publicName
  • DISPLAY-NAMEspec.version
  • SHORT-DESCRIPTIONspec.

이것은 시각적으로 다음과 같이 표현됩니다.

패키지 구성

설치 전에 tanzu CLI에서 패키지를 구성할 수 있습니다. 이 작업은 각 패키지에 대해 –values-schema를 검사하고 구성할 YAML 값의 –values-file을 제공하여 수행됩니다. 또는 GitHub에서 각 패키지에 포함된 config/value.yaml 파일을 조회할 수 있습니다. 다음과 같은 방법으로 구성을 캡처해 보십시오.

a. –values-schema 플래그를 사용하여 가능한 값 목록을 검색합니다.

tanzu package available get contour.community.tanzu.vmware.com/1.17.1 --values-schema

| Retrieving package details for contour.community.tanzu.vmware.com/1.17.1...
  KEY                                  DEFAULT         TYPE     DESCRIPTION
  contour.logLevel                     info            string   The Contour log level. Valid options are info and debug.
  contour.replicas                     2               integer  How many Contour pod replicas to have.
  contour.useProxyProtocol             false           boolean  Whether to enable PROXY protocol for all Envoy listeners.
  contour.configFileContents           <nil>           object   The YAML contents of the Contour config file. See https://projectcontour.io/docs/v1.17.1/configuration/#configuration-file for more information.
  envoy.logLevel                       info            string   The Envoy log level.
  envoy.service.annotations            <nil>           object   Annotations to set on the Envoy service.
  envoy.service.externalTrafficPolicy  Local           string   The external traffic policy for the Envoy service.
  envoy.service.loadBalancerIP         <nil>           string   If type == LoadBalancer, the desired load balancer IP for the Envoy service.
  envoy.service.nodePorts.http         <nil>           integer  If type == NodePort, the node port number to expose Envoy's HTTP listener on. If not specified, a node port will be auto-assigned by Kubernetes.
  envoy.service.nodePorts.https        <nil>           integer  If type == NodePort, the node port number to expose Envoy's HTTPS listener on. If not specified, a node port will be auto-assigned by Kubernetes.
  envoy.service.type                   LoadBalancer    string   The type of Kubernetes service to provision for Envoy.
  envoy.terminationGracePeriodSeconds  300             integer  The termination grace period, in seconds, for the Envoy pods.
  envoy.hostNetwork                    false           boolean  Whether to enable host networking for the Envoy pods.
  envoy.hostPorts.http                 80              integer  If enable == true, the host port number to expose Envoy's HTTP listener on.
  envoy.hostPorts.https                443             integer  If enable == true, the host port number to expose Envoy's HTTPS listener on.
  envoy.hostPorts.enable               false           boolean  Whether to enable host ports. If false, http and https are ignored.
  namespace                            projectcontour  string   The namespace in which to deploy Contour and Envoy.
  certificates.renewBefore             360h            string   If using cert-manager, how long before expiration the certificates should be renewed. If useCertManager is false, this field is ignored.
  certificates.useCertManager          false           boolean  Whether to use cert-manager to provision TLS certificates for securing communication between Contour and Envoy. If false, the upstream Contour certgen job will be used to provision certificates. If true, the cert-manager addon must be installed in the cluster.
  certificates.duration                8760h           string   If using cert-manager, how long the certificates should be valid for. If useCertManager is false, this field is ignored.
  • KEY values.yaml 파일에 입력할 수 있는 yaml 액세스 키를 나타냅니다. 중첩된 키는 . 로 표시됩니다.
  • DEFAULT는 제공된 values.yaml 파일에 구성되지 않은 경우 기본값을 나타냅니다.
  • TYPE은 values.yaml 파일의 키/값 쌍에서 예상되는 yaml 유형을 알려줍니다.
  • Description은 값이 패키지에 대해 구성하는 내용에 대한 간단한 설명입니다.

b. values.yaml 파일을 만들고 –values-schema를 기반으로 네임스페이스 및 logLevel 값을 정의합니다.

namespace: custom-namespace
contour:
  logLevel: debug

c. 설치하는 동안 value.yaml 파일을 적용합니다.

tanzu package install contour \
  --package-name contour.community.tanzu.vmware.com \
  --version 1.17.1 \
  --values-file values.yaml

참고: 값 파일은 ytt 구문을 사용해야 합니다. 자세한 내용은 Carvel ytt 문서를 참조하십시오.

패키지 설치

Tanzu CLI는 패키지를 설치할 수 있습니다. 여기서 설치는 워크로드를 클러스터에 배포하려는 의향을 나타냅니다. 이 작업은 InstalledPackage CR를 사용하여 수행합니다. 클러스터에 존재하면 kapp 컨트롤러(서버 측)가 생성 및 조정해야 하는 리소스를 해결할 수 있습니다.

tanzu CLI 측의 주요 작업은 Package CR를 사용자의 요구에 따라 InstalledPackage로 변환하는 것입니다. 클러스터에서 사용 가능한 다음과 같은 패키지를 고려하십시오.

tanzu package available list
| Retrieving available packages...
  NAME                                           DISPLAY-NAME        SHORT-DESCRIPTION
  cert-manager.community.tanzu.vmware.com        cert-manager        Certificate management
  contour-operator.community.tanzu.vmware.com    contour-operator    Layer 7 Ingress
  contour.community.tanzu.vmware.com             Contour             An ingress controller
  external-dns.community.tanzu.vmware.com        external-dns        This package provides DNS synchronization functionality.
  fluent-bit.community.tanzu.vmware.com          fluent-bit          Fluent Bit is a fast Log Processor and Forwarder
  gatekeeper.community.tanzu.vmware.com          gatekeeper          policy management
  grafana.community.tanzu.vmware.com             grafana             Visualization and analytics software
  harbor.community.tanzu.vmware.com              Harbor              OCI Registry
  knative-serving.community.tanzu.vmware.com     knative-serving     Knative Serving builds on Kubernetes to support deploying and serving of applications and functions as serverless containers
  local-path-storage.community.tanzu.vmware.com  local-path-storage  This package provides local path node storage and primarily supports RWO AccessMode.
  multus-cni.community.tanzu.vmware.com          multus-cni          This package provides the ability for enabling attaching multiple network interfaces to pods in Kubernetes
  prometheus.community.tanzu.vmware.com          prometheus          A time series database for your metrics
  velero.community.tanzu.vmware.com              velero              Disaster recovery capabilities

사용자가 knative-serving.tce.vmware.com:0.21.0-vmware0 패키지를 설치하려는 경우 다음 명령을 실행할 수 있습니다.

tanzu package install knative-serving.tce.vmware.com

Looking up package to install: knative-serving.tce.vmware.com:
Installed package in default/knative-serving.tce.vmware.com:0.21.0-vmware0

이 명령을 실행할 때 tanzu 클라이언트는 다음을 수행합니다.

  1. knative-serving.tce.vmware.com:0.21.0-vmware0 패키지의 내용을 읽어보십시오.

다음은 패키지 내용물의 예입니다.

apiVersion: package.carvel.dev/v1alpha1
kind: Package
metadata:
  # Resource name. Should not be referenced by InstalledPackage.
  # Should only be populated to comply with Kubernetes resource schema.
  # spec.publicName/spec.version fields are primary identifiers
  # used in references from InstalledPackage
  name: knative.tce.vmware.com.0.21.0-vmware0
  # Package is a cluster scoped resource, so no namespace
spec:
  # Name of the package; Referenced by InstalledPackage (required)
  publicName: knative.tce.vmware.com
  # Package version; Referenced by InstalledPackage;
  # Must be valid semver (required)
  version: 0.21.0-vmware0
  # App template used to create the underlying App CR.
  # See 'App CR Spec' docs for more info
  template:
    spec:
      fetch:
      - imgpkgBundle:
          image: registry.tkg.vmware.run/tkg-knative@sha256:...
      template:
      - ytt:
          paths:
          - config/
      - kbld:
          paths:
          # - must be quoted when included with paths
          - "-"
          - .imgpkg/images.yml
      deploy:
      - kapp: {}

2. knative-serving-0-21 InstalledPackage를 만들었습니다.

다음은 InstalledPackage 콘텐츠의 예입니다.

apiVersion: install.package.carvel.dev/v1alpha1
kind: InstalledPackage
metadata:
  name: knative-serving-0-21
  namespace: my-ns
spec:
  # specifies service account that will be used to install underlying package contents
  serviceAccountName: knative-sa
  packageRef:
    # Public name of the package to install. (required)
    publicName: knative.tce.vmware.com
    # Specifies a specific version of a package to install (optional)
    # Either version or versionSelection is required.
    version: 0.21.0-vmware0
    # Selects version of a package based on constraints provided (optional)
    # Either version or versionSelection is required.
    versionSelection:
      # Constraint to limit acceptable versions of a package;
      # Latest version satisying the contraint is chosen;
      # Newly available, acceptable later versions are picked up and installed automatically. (optional)
      constraint: ">0.20"
      # Include prereleases when selecting version. (optional)
      prereleases: {}
# Populated by the controller
status:
  packageRef:
    # Kubernetes resource name of the package chosen against the constraints
    name: knative.tce.vmware.com.0.21.0-vmware0
  # Derived from the underlying App's Status
  conditions:
  - type: ValuesSchemaCheckFailed
  - type: ReconcileSucceeded
  - type: ReconcileFailed
  - type: Reconciling

3. 클러스터에 InstalledPackage를 적용했습니다.

이것은 시각적으로 다음과 같이 표현됩니다.

패키지 구성 포함

패키지 구성에 설명된 대로 추가 구성을 설치할 수 있습니다. 설치 중에 –values-file/-f를 플래그로 포함할 수 있습니다. 위의 예제는 다음을 사용하여 다시 실행할 수 있습니다.

tanzu package install knative-serving.tce.vmware.com --values-file knative-serving-config.yaml

Looking up package to install: knative-serving.tce.vmware.com:
Installed package in default/knative-serving.tce.vmware.com:0.21.0-vmware0

이 구성을 포함하면 다음과 같은 작업을 수행할 수 있습니다.

  1. Kubernetes의 시크릿으로 knative-serving-config.yaml을 적용하세요.

예를 들어 다음과 같습니다.

---
apiVersion: v1
kind: Secret
metadata:
  name: knative-serving-config
stringData:
  values.yml: |
    #@data/values
    ---
    hello_msg: "hi"

2. 적용하기 전에 spec.values를 InstalledPackage CR에 추가하십시오.

# Values to be included in package's templating step
  # (currently only included in the first templating step) (optional)
  values:
  - secretRef:
      name: knative-serving-config

패키지 리포지토리 탐색

tanzu CLI는 클러스터에 알려진 모든 패키지 리포지토리를 나열할 수 있습니다. 기본적으로 모든 PackageRepository 개체의 목록입니다. CLI 상호 작용은 다음과 같습니다.

tanzu package repository list

NAME               VERSION
tce-main           1.12

위에서 tanzu CLI는 이미 존재하는 객체의 메타데이터를 집계하고 나열합니다. 각 PackageRepository 인스턴스에서 다음을 수행합니다.

  • NAME : metadata.name
  • VERSION : 현재 알 수 없습니다. 패키지 리포 버전이 지정됩니까?

패키지 리포지토리 생성

tangu CLI는 패키지 리포지토리를 설치할 수 있습니다. 그러면 해당 repo에서 참조되는 모든 패키지가 생성되어 kapp 컨트롤러에 의해 클러스터에서 사용할 수 있게 됩니다. 패키지 리포지토리가 여러 패키지 매니페스트를 포함하는 OCI 번들을 가리킵니다. tansu CLI는 PackageRepository CR만 적용하면 됩니다. 이 저장소 매니페스트는 Tanzu Community Edition GitHub repo에서 확인할 수 있습니다. 흐름은 다음과 같이 보일 수 있습니다.

tanzu package repository install -f ${REPO_MANIFEST_LOCATION}

installed package repo

흐름으로 보면 다음과 같습니다.

패키지 리포지토리를 삭제

tanzu CLI는 패키지 리포지토리를 삭제할 수 있습니다. 다시 해당 repo에서 참조된 모든 패키지가 kapp-controller에 의해 삭제됩니다.

tanzu package repository delete ${REPO_NAME}

deleted package repo

흐름은 다음과 같이 보일 수 있습니다.

설계 보류 세부 정보

이 섹션에서는 설계 작업이 필요한 문제를 다룹니다.

패키지 및 PackageRepository를 업그레이드하는 중입니다

Package 및 PackageRepsitory 업그레이드가 클라이언트측 관점에서 작동하는 방식에 대한 설계가 필요합니다.

출처 : https://tanzucommunityedition.io/docs/latest/designs/package-management/
답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

You May Also Like