IK.AM

@making's tech note


Tanzu Application Platform 1.5 (Iterate Profile) をKindにインストールするメモ

🗃 {Dev/CaaS/Kubernetes/TAP}
🏷 Kubernetes 🏷 Cartographer 🏷 kind 🏷 Tanzu 🏷 TAP 
🗓 Updated at 2023-07-18T07:53:22Z  🗓 Created at 2023-04-11T18:49:27Z   🌎 English Page

⚠️ 本記事の内容はVMwareによってサポートされていません。 記事の内容で生じた問題については自己責任で対応し、 VMwareサポート窓口には問い合わせないでください

Tanzu Application Platform 1.5 をKindにインストールします。

Intel版のMacとApple Silicon版のMacで試しました。

本記事ではTAPをInstallし、"Hello World"なアプリケーションをソースコードからデプロイする機能("Source to URL")を試します。

公式ドキュメントはこちら
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/install.html


目次

Kindクラスタの作成

Dockerには5 CPU, 8 GBメモリ以上を割り当ててください。(TAP 1.4の時よりもインストールされるコンポーネントが増えたの必要なリソースも増えています)

cat <<EOF > kind-expose-port.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    listenAddress: "0.0.0.0"
  - containerPort: 443
    hostPort: 443
    listenAddress: "0.0.0.0"
EOF
kind create cluster --config kind-expose-port.yaml --image kindest/node:v1.26.6

Pivnet CLIのインストール

ここでは pivnet CLIを使用して必要なソフトウェアをダウンロードします。 pivnet CLIはbrewでインストールできます。

brew install pivotal/tap/pivnet-cli

VMware Tanzu Network のAPI Tokenを取得して、pivnet CLIでログインします。

pivnet login --api-token=<API Token>

🍎 Apple Siliconの場合は https://github.com/anthonydahanne/pivnet-cli/releases/tag/anthony-dev-20230323 からpivnetのバイナリをダウンロードできます。

EULAの承諾

初めてインストールする場合は、以下のコンポーネントのEULAをAcceptしてください。

⚠️ EULAで定められている使用期間は30日間です。とは言え、特にソフトウェア的に制限がかけられているわけではありません。

Tanzu CLIのインストール

# For Mac
pivnet download-product-files --product-slug='tanzu-application-platform' --release-version='1.5.3' --glob='tanzu-framework-darwin-amd64-*.tar'
# For Linux
pivnet download-product-files --product-slug='tanzu-application-platform' --release-version='1.5.3' --glob='tanzu-framework-linux-amd64-*.tar'
# For Windows
pivnet download-product-files --product-slug='tanzu-application-platform' --release-version='1.5.3' --glob='tanzu-framework-windows-amd64-*.zip'

🍎 darwin-amd64-...というファイル名ですが、Apple Siliconでも動作しました。

tar xvf tanzu-framework-*-amd64-*.tar
install cli/core/v0.28.1/tanzu-core-*_amd64 /usr/local/bin/tanzu
export TANZU_CLI_NO_INIT=true
$ tanzu version
version: v0.28.1
buildDate: 2023-03-07
sha: 0e6704777-dirty

プラグインのインストール

tanzu plugin clean
tanzu plugin install --local cli all

Cluster Essentials for VMware Tanzuのインストール

TAPのインストールに必要なKapp ControllerとSecretgen Controllerをデプロイするために Cluster Essentials for VMware Tanzu をインストールします。

# Mac
pivnet download-product-files --product-slug='tanzu-cluster-essentials' --release-version='1.5.2' --glob='tanzu-cluster-essentials-darwin-amd64-*'
# Linux
pivnet download-product-files --product-slug='tanzu-cluster-essentials' --release-version='1.5.2' --glob='tanzu-cluster-essentials-linux-amd64-*'
TANZUNET_USERNAME=...
TANZUNET_PASSWORD=...

mkdir tanzu-cluster-essentials
tar xzvf tanzu-cluster-essentials-*-amd64-*.tgz -C tanzu-cluster-essentials

export INSTALL_BUNDLE=registry.tanzu.vmware.com/tanzu-cluster-essentials/cluster-essentials-bundle:1.5.2
export INSTALL_REGISTRY_HOSTNAME=registry.tanzu.vmware.com
export INSTALL_REGISTRY_USERNAME=${TANZUNET_USERNAME}
export INSTALL_REGISTRY_PASSWORD=${TANZUNET_PASSWORD}
cd tanzu-cluster-essentials
./install.sh --yes
cd ..
$ kubectl get pod -n kapp-controller
NAME                               READY   STATUS    RESTARTS   AGE
kapp-controller-589c94578d-gtzzh   2/2     Running   0          54s

$ kubectl get pod -n secretgen-controller
NAME                                    READY   STATUS    RESTARTS   AGE
secretgen-controller-5b69875cf5-tsczq   1/1     Running   0          35s

Tanzu Application Platformのインストール

TAP用Package Repositoryの登録

TANZUNET_USERNAME=...
TANZUNET_PASSWORD=...

kubectl create ns tap-install

tanzu secret registry add tap-registry \
  --username "${TANZUNET_USERNAME}" \
  --password "${TANZUNET_PASSWORD}" \
  --server registry.tanzu.vmware.com \
  --export-to-all-namespaces \
  --yes \
  --namespace tap-install

tanzu package repository add tanzu-tap-repository-1.5.3 \
  --url registry.tanzu.vmware.com/tanzu-application-platform/tap-packages:1.5.3 \
  --namespace tap-install
$ tanzu package available list --namespace tap-install
  NAME                                                 DISPLAY-NAME                                                              
  accelerator.apps.tanzu.vmware.com                    Application Accelerator for VMware Tanzu                                  
  api-portal.tanzu.vmware.com                          API portal                                                                
  apis.apps.tanzu.vmware.com                           API Auto Registration for VMware Tanzu                                    
  apiserver.appliveview.tanzu.vmware.com               Application Live View ApiServer for VMware Tanzu                          
  app-scanning.apps.tanzu.vmware.com                   Supply Chain Security Tools - App Scanning (Alpha)                        
  application-configuration-service.tanzu.vmware.com   Application Configuration Service                                         
  backend.appliveview.tanzu.vmware.com                 Application Live View for VMware Tanzu                                    
  bitnami.services.tanzu.vmware.com                    bitnami-services                                                          
  buildservice.tanzu.vmware.com                        Tanzu Build Service                                                       
  carbonblack.scanning.apps.tanzu.vmware.com           VMware Carbon Black for Supply Chain Security Tools - Scan                
  cartographer.tanzu.vmware.com                        Cartographer                                                              
  cnrs.tanzu.vmware.com                                Cloud Native Runtimes                                                     
  connector.appliveview.tanzu.vmware.com               Application Live View Connector for VMware Tanzu                          
  controller.source.apps.tanzu.vmware.com              Tanzu Source Controller                                                   
  conventions.appliveview.tanzu.vmware.com             Application Live View Conventions for VMware Tanzu                        
  crossplane.tanzu.vmware.com                          crossplane                                                                
  developer-conventions.tanzu.vmware.com               Tanzu App Platform Developer Conventions                                  
  eventing.tanzu.vmware.com                            Eventing                                                                  
  external-secrets.apps.tanzu.vmware.com               External Secrets Operator                                                 
  fluxcd.source.controller.tanzu.vmware.com            Flux Source Controller                                                    
  grype.scanning.apps.tanzu.vmware.com                 Grype for Supply Chain Security Tools - Scan                              
  learningcenter.tanzu.vmware.com                      Learning Center for Tanzu Application Platform                            
  metadata-store.apps.tanzu.vmware.com                 Supply Chain Security Tools - Store                                       
  namespace-provisioner.apps.tanzu.vmware.com          Namespace Provisioner                                                     
  ootb-delivery-basic.tanzu.vmware.com                 Tanzu App Platform Out of The Box Delivery Basic                          
  ootb-supply-chain-basic.tanzu.vmware.com             Tanzu App Platform Out of The Box Supply Chain Basic                      
  ootb-supply-chain-testing-scanning.tanzu.vmware.com  Tanzu App Platform Out of The Box Supply Chain with Testing and Scanning  
  ootb-supply-chain-testing.tanzu.vmware.com           Tanzu App Platform Out of The Box Supply Chain with Testing               
  ootb-templates.tanzu.vmware.com                      Tanzu App Platform Out of The Box Templates                               
  policy.apps.tanzu.vmware.com                         Supply Chain Security Tools - Policy Controller                           
  scanning.apps.tanzu.vmware.com                       Supply Chain Security Tools - Scan                                        
  service-bindings.labs.vmware.com                     Service Bindings for Kubernetes                                           
  services-toolkit.tanzu.vmware.com                    Services Toolkit                                                          
  snyk.scanning.apps.tanzu.vmware.com                  Snyk for Supply Chain Security Tools - Scan                               
  spring-boot-conventions.tanzu.vmware.com             Tanzu Spring Boot Conventions Server                                      
  spring-cloud-gateway.tanzu.vmware.com                Spring Cloud Gateway                                                      
  sso.apps.tanzu.vmware.com                            AppSSO                                                                    
  tap-auth.tanzu.vmware.com                            Default roles for Tanzu Application Platform                              
  tap-gui.tanzu.vmware.com                             Tanzu Application Platform GUI                                            
  tap-telemetry.tanzu.vmware.com                       Telemetry Collector for Tanzu Application Platform                        
  tap.tanzu.vmware.com                                 Tanzu Application Platform                                                
  tekton.tanzu.vmware.com                              Tekton Pipelines                                                          
  workshops.learningcenter.tanzu.vmware.com            Workshop Building Tutorial                                                

Iterate Profileのインストール

iterate profileをインストールするために、次のtap-values.yamlを作成します。 5CPUでもインストールできるように不要なpackageをexcluded_packagesに追加しています。

Builderの作成などに使用するBuildservice用のSecretを作成します。

GITHUB_USERNAME=...
GITHUB_API_TOKEN=...

tanzu secret registry add buildservice-regcred \
  --username ${GITHUB_USERNAME} \
  --password ${GITHUB_API_TOKEN} \
  --server ghcr.io \
  --yes \
  --namespace tap-install

cat <<EOF > tap-values.yaml
shared:
  ingress_domain: 127-0-0-1.sslip.io
  image_registry:
    project_path: ghcr.io/${GITHUB_USERNAME}
    secret:
      name: buildservice-regcred
      namespace: tap-install
  kubernetes_version: "1.26"

ceip_policy_disclosed: true
profile: iterate

supply_chain: basic

contour:
  contour:
    replicas: 1
  envoy:
    service:
      type: NodePort
    hostPorts:
      enable: true
# 以下リソース節約用
cnrs:
  lite:
    enable: true
  pdb:
    enable: false
cartographer:
  cartographer:
    resources:
      requests:
        cpu: 100m
        memory: 200Mi

excluded_packages:
- policy.apps.tanzu.vmware.com
- image-policy-webhook.signing.apps.tanzu.vmware.com
- eventing.tanzu.vmware.com
- sso.apps.tanzu.vmware.com
EOF

*.127-0-0-1.sslip.io127.0.0.1に解決されます。


ℹ️ MetalLBが利用できる環境(Kind on LinuxまたはMacでOrbStackを利用する場合)は、127-0-0-1.sslip.ioの代わりにMetalLBのサポートするExternal IPのレンジでEnvoyのIPを指定し、ドメイン名に使用することができます。例えば、172.19.255.200が利用できる場合は、以下のような設定になります。

shared:
  ingress_domain: tap.172-19-255-200.sslip.io
  # ...

contour:
  # ...
  envoy:
    service:
      type: LoadBalancer
      loadBalancerIP: 172.19.255.200

# ...

TAPをインストールします。

tanzu package install tap \
  -p tap.tanzu.vmware.com \
  -v 1.5.3 \
  --values-file tap-values.yaml \
  -n tap-install

CLIのpackageプラグインがアップデートされて、以前のバージョンに比べてインストールの進捗が分かりやすくなりました。インストールが終わるまで10分強かかります。

1:58:57AM: Creating service account 'tap-tap-install-sa'
1:58:57AM: Creating cluster admin role 'tap-tap-install-cluster-role'
1:58:57AM: Creating cluster role binding 'tap-tap-install-cluster-rolebinding'
1:58:57AM: Creating secret 'tap-tap-install-values'
1:58:57AM: Creating overlay secrets
1:58:57AM: Creating package install resource
1:58:57AM: Waiting for PackageInstall reconciliation for 'tap'
1:58:57AM: Fetch started (6s ago)
1:59:03AM: Fetching 
      | apiVersion: vendir.k14s.io/v1alpha1
      | directories:
      | - contents:
      |   - imgpkgBundle:
      |       image: registry.tanzu.vmware.com/tanzu-application-platform/tap-packages@sha256:f196431b671a95b60cfa7d57724f56f00e394fc8ea8579228970f473120fc066
      |     path: .
      |   path: "0"
      | kind: LockConfig
      | 
1:59:03AM: Fetch succeeded 
1:59:03AM: Template succeeded 
1:59:03AM: Deploy started (2s ago)
1:59:05AM: Deploying 
      | Target cluster 'https://10.96.0.1:443' (nodes: kind-control-plane)
      | Changes
      | Namespace    Name                                    Kind                Age  Op      Op st.  Wait to    Rs  Ri
      | (cluster)    tap-install-cluster-admin-role          ClusterRole         -    create  -       reconcile  -   -
      | ^            tap-install-cluster-admin-role-binding  ClusterRoleBinding  -    create  -       reconcile  -   -
      | tap-install  api-auto-registration                   PackageInstall      -    create  -       reconcile  -   -
      | ^            api-auto-registration-values-ver-1      Secret              -    create  -       reconcile  -   -
      | ^            appliveview-apiserver                   PackageInstall      -    create  -       reconcile  -   -
      | ^            appliveview-apiserver-values-ver-1      Secret              -    create  -       reconcile  -   -
      | ^            appliveview-connector                   PackageInstall      -    create  -       reconcile  -   -
      | ^            appliveview-connector-values-ver-1      Secret              -    create  -       reconcile  -   -
      | ^            appliveview-conventions                 PackageInstall      -    create  -       reconcile  -   -
      | ^            appliveview-conventions-values-ver-1    Secret              -    create  -       reconcile  -   -
      | ^            bitnami-services                        PackageInstall      -    create  -       reconcile  -   -
      | ^            bitnami-services-values-ver-1           Secret              -    create  -       reconcile  -   -
      | ^            buildservice                            PackageInstall      -    create  -       reconcile  -   -
      | ^            buildservice-values-ver-1               Secret              -    create  -       reconcile  -   -
      | ^            cartographer                            PackageInstall      -    create  -       reconcile  -   -
      | ^            cartographer-values-ver-1               Secret              -    create  -       reconcile  -   -
      | ^            cert-manager                            PackageInstall      -    create  -       reconcile  -   -
      | ^            cert-manager-values-ver-1               Secret              -    create  -       reconcile  -   -
      | ^            cnrs                                    PackageInstall      -    create  -       reconcile  -   -
      | ^            cnrs-values-ver-1                       Secret              -    create  -       reconcile  -   -
      | ^            contour                                 PackageInstall      -    create  -       reconcile  -   -
      | ^            contour-values-ver-1                    Secret              -    create  -       reconcile  -   -
      | ^            crossplane                              PackageInstall      -    create  -       reconcile  -   -
      | ^            crossplane-values-ver-1                 Secret              -    create  -       reconcile  -   -
      | ^            developer-conventions                   PackageInstall      -    create  -       reconcile  -   -
      | ^            developer-conventions-values-ver-1      Secret              -    create  -       reconcile  -   -
      | ^            fluxcd-source-controller                PackageInstall      -    create  -       reconcile  -   -
      | ^            fluxcd-source-controller-values-ver-1   Secret              -    create  -       reconcile  -   -
      | ^            namespace-provisioner                   PackageInstall      -    create  -       reconcile  -   -
      | ^            namespace-provisioner-values-ver-1      Secret              -    create  -       reconcile  -   -
      | ^            ootb-delivery-basic                     PackageInstall      -    create  -       reconcile  -   -
      | ^            ootb-delivery-basic-values-ver-1        Secret              -    create  -       reconcile  -   -
      | ^            ootb-supply-chain-basic                 PackageInstall      -    create  -       reconcile  -   -
      | ^            ootb-supply-chain-basic-values-ver-1    Secret              -    create  -       reconcile  -   -
      | ^            ootb-templates                          PackageInstall      -    create  -       reconcile  -   -
      | ^            ootb-templates-values-ver-1             Secret              -    create  -       reconcile  -   -
      | ^            service-bindings                        PackageInstall      -    create  -       reconcile  -   -
      | ^            services-toolkit                        PackageInstall      -    create  -       reconcile  -   -
      | ^            services-toolkit-values-ver-1           Secret              -    create  -       reconcile  -   -
      | ^            source-controller                       PackageInstall      -    create  -       reconcile  -   -
      | ^            source-controller-values-ver-1          Secret              -    create  -       reconcile  -   -
      | ^            spring-boot-conventions                 PackageInstall      -    create  -       reconcile  -   -
      | ^            springboot-conventions-values-ver-1     Secret              -    create  -       reconcile  -   -
      | ^            tap-auth                                PackageInstall      -    create  -       reconcile  -   -
      | ^            tap-install-sa                          ServiceAccount      -    create  -       reconcile  -   -
      | ^            tap-telemetry                           PackageInstall      -    create  -       reconcile  -   -
      | ^            tap-telemetry-values-ver-1              Secret              -    create  -       reconcile  -   -
      | ^            tekton-pipelines                        PackageInstall      -    create  -       reconcile  -   -
      | ^            tekton-pipelines-values-ver-1           Secret              -    create  -       reconcile  -   -
      | Op:      49 create, 0 delete, 0 update, 0 noop, 0 exists
      | Wait to: 49 reconcile, 0 delete, 0 noop
      | 4:59:03PM: ---- applying 24 changes [0/49 done] ----
      | 4:59:03PM: create secret/api-auto-registration-values-ver-1 (v1) namespace: tap-install
...
      | 5:08:30PM: ---- waiting on 2 changes [47/49 done] ----
      | 5:08:30PM: ok: reconcile packageinstall/cnrs (packaging.carvel.dev/v1alpha1) namespace: tap-install
      | 5:08:30PM: ongoing: reconcile packageinstall/buildservice (packaging.carvel.dev/v1alpha1) namespace: tap-install
      | 5:08:30PM:  ^ Reconciling
      | 5:08:30PM: ---- waiting on 1 changes [48/49 done] ----
2:09:24AM: Deploy succeeded (1s ago)

Appリソースが全てReconcile succeededになっていることを確認します。

$ kubectl get app -n tap-install 
NAME                       DESCRIPTION           SINCE-DEPLOY   AGE
api-auto-registration      Reconcile succeeded   80s            22m
appliveview-apiserver      Reconcile succeeded   11m            22m
appliveview-connector      Reconcile succeeded   4m52s          26m
appliveview-conventions    Reconcile succeeded   9m51s          20m
bitnami-services           Reconcile succeeded   11s            20m
buildservice               Reconcile succeeded   6m33s          26m
cartographer               Reconcile succeeded   45s            22m
cert-manager               Reconcile succeeded   2m11s          26m
cnrs                       Reconcile succeeded   7m29s          19m
contour                    Reconcile succeeded   9m29s          22m
crossplane                 Reconcile succeeded   4m15s          26m
developer-conventions      Reconcile succeeded   2s             20m
fluxcd-source-controller   Reconcile succeeded   5m44s          26m
namespace-provisioner      Reconcile succeeded   5m59s          26m
ootb-delivery-basic        Reconcile succeeded   19s            20m
ootb-supply-chain-basic    Reconcile succeeded   18s            20m
ootb-templates             Reconcile succeeded   25s            20m
service-bindings           Reconcile succeeded   5m55s          26m
services-toolkit           Reconcile succeeded   24s            22m
source-controller          Reconcile succeeded   68s            22m
spring-boot-conventions    Reconcile succeeded   9m44s          20m
tap                        Reconcile succeeded   6m32s          27m
tap-auth                   Reconcile succeeded   6m17s          26m
tap-telemetry              Reconcile succeeded   6m31s          26m
tekton-pipelines           Reconcile succeeded   15m            26m

インストールされたパッケージは次の通りです。

$ tanzu package installed list -n tap-install
  NAME                      PACKAGE-NAME                                 PACKAGE-VERSION   STATUS               
  api-auto-registration     apis.apps.tanzu.vmware.com                   0.3.3             Reconcile succeeded  
  appliveview-apiserver     apiserver.appliveview.tanzu.vmware.com       1.5.3             Reconcile succeeded  
  appliveview-connector     connector.appliveview.tanzu.vmware.com       1.5.3             Reconcile succeeded  
  appliveview-conventions   conventions.appliveview.tanzu.vmware.com     1.5.3             Reconcile succeeded  
  bitnami-services          bitnami.services.tanzu.vmware.com            0.1.0             Reconcile succeeded  
  buildservice              buildservice.tanzu.vmware.com                1.10.10           Reconcile succeeded  
  cartographer              cartographer.tanzu.vmware.com                0.7.3             Reconcile succeeded  
  cert-manager              cert-manager.tanzu.vmware.com                2.3.1             Reconcile succeeded  
  cnrs                      cnrs.tanzu.vmware.com                        2.2.0             Reconcile succeeded  
  contour                   contour.tanzu.vmware.com                     1.22.5+tap.1.5.0  Reconcile succeeded  
  crossplane                crossplane.tanzu.vmware.com                  0.1.1             Reconcile succeeded  
  developer-conventions     developer-conventions.tanzu.vmware.com       0.10.0            Reconcile succeeded  
  fluxcd-source-controller  fluxcd.source.controller.tanzu.vmware.com    0.27.0+tap.10     Reconcile succeeded  
  namespace-provisioner     namespace-provisioner.apps.tanzu.vmware.com  0.3.1             Reconcile succeeded  
  ootb-delivery-basic       ootb-delivery-basic.tanzu.vmware.com         0.12.6            Reconcile succeeded  
  ootb-supply-chain-basic   ootb-supply-chain-basic.tanzu.vmware.com     0.12.6            Reconcile succeeded  
  ootb-templates            ootb-templates.tanzu.vmware.com              0.12.6            Reconcile succeeded  
  service-bindings          service-bindings.labs.vmware.com             0.9.1             Reconcile succeeded  
  services-toolkit          services-toolkit.tanzu.vmware.com            0.10.2            Reconcile succeeded  
  source-controller         controller.source.apps.tanzu.vmware.com      0.7.1             Reconcile succeeded  
  spring-boot-conventions   spring-boot-conventions.tanzu.vmware.com     1.5.3             Reconcile succeeded  
  tap                       tap.tanzu.vmware.com                         1.5.3             Reconcile succeeded  
  tap-auth                  tap-auth.tanzu.vmware.com                    1.1.0             Reconcile succeeded  
  tap-telemetry             tap-telemetry.tanzu.vmware.com               0.5.1             Reconcile succeeded  
  tekton-pipelines          tekton.tanzu.vmware.com                      0.41.0+tap.8      Reconcile succeeded   

デプロイされたPodは次の通りです。

$ kubectl get pod -A | grep -v kube-system  | grep -v local-path-storage
NAMESPACE                    NAME                                                           READY   STATUS              RESTARTS   AGE
api-auto-registration        api-auto-registration-controller-957b547bf-49vmk               1/1     Running             0          19m
app-live-view-connector      application-live-view-connector-xkzw9                          1/1     Running             0          23m
app-live-view-conventions    appliveview-webhook-7469cc6fb9-4lbr8                           1/1     Running             0          17m
appliveview-tokens-system    appliveview-apiserver-55c76bb874-mqcgt                         1/1     Running             0          19m
build-service                build-pod-image-fetcher-sjk79                                  5/5     Running             0          23m
build-service                dependency-updater-controller-86d9ddf87-zhwmz                  1/1     Running             0          23m
build-service                secret-syncer-controller-977b49744-grcld                       1/1     Running             0          23m
build-service                warmer-controller-64bb6f8444-vmswd                             1/1     Running             0          23m
cartographer-system          cartographer-controller-7d8b78fb76-9xf6j                       1/1     Running             0          19m
cartographer-system          cartographer-conventions-controller-manager-7d5bbddc9c-gw9c8   1/1     Running             0          19m
cert-injection-webhook       cert-injection-webhook-b96d894ff-54tss                         1/1     Running             0          23m
cert-manager                 cert-manager-7684b45c7-l7gqf                                   1/1     Running             0          22m
cert-manager                 cert-manager-cainjector-54fc6c9465-rrs9g                       1/1     Running             0          22m
cert-manager                 cert-manager-webhook-74b77dc985-7bbb7                          1/1     Running             0          22m
crossplane-system            crossplane-b6c8d88f-q426v                                      1/1     Running             0          23m
crossplane-system            crossplane-rbac-manager-744f4df4d4-72tr8                       1/1     Running             0          23m
crossplane-system            provider-helm-a3a14b07b79a-67f8c4559d-8cxzv                    1/1     Running             0          20m
crossplane-system            provider-kubernetes-8039f7e56376-68dfcf8dcb-x22h5              1/1     Running             0          20m
developer-conventions        webhook-7cc4ff6b6b-k85rz                                       1/1     Running             0          17m
flux-system                  fluxcd-source-controller-76f5b76fd5-fjjkw                      1/1     Running             0          23m
kapp-controller              kapp-controller-785c6cd487-6wt28                               2/2     Running             0          42m
knative-serving              activator-6fd6df6546-f8j6z                                     1/1     Running             0          16m
knative-serving              autoscaler-b84975f6d-tv79r                                     1/1     Running             0          16m
knative-serving              autoscaler-hpa-5fd44fc9b8-7jzqp                                1/1     Running             0          16m
knative-serving              controller-85f56865f9-75jlz                                    1/1     Running             0          16m
knative-serving              domain-mapping-564795d794-cvr94                                1/1     Running             0          16m
knative-serving              domainmapping-webhook-5c97b5dd8d-g6wxg                         1/1     Running             0          16m
knative-serving              net-certmanager-controller-84c6759f4d-lntkl                    1/1     Running             0          16m
knative-serving              net-certmanager-webhook-7b9fb6c5f7-jn4nv                       1/1     Running             0          16m
knative-serving              net-contour-controller-5bfbc75f69-99mhf                        1/1     Running             0          16m
knative-serving              webhook-6c97f87974-qj4fm                                       1/1     Running             0          16m
kpack                        kpack-controller-787fcfbdc6-2r5q2                              1/1     Running             0          23m
kpack                        kpack-webhook-7c76588d6c-qmhsd                                 1/1     Running             0          23m
secretgen-controller         secretgen-controller-7f44f89697-hpxzf                          1/1     Running             0          41m
service-bindings             manager-665568685f-cmf77                                       1/1     Running             0          23m
services-toolkit             resource-claims-apiserver-c6c645f8d-5gszb                      1/1     Running             0          19m
services-toolkit             services-toolkit-controller-manager-765f544cbf-gz8l6           1/1     Running             0          19m
source-system                source-controller-manager-6d8bc6d6fb-795d2                     1/1     Running             0          19m
spring-boot-convention       spring-boot-webhook-7bf949d6d4-k828m                           1/1     Running             0          17m
stacks-operator-system       controller-manager-69474b77b8-9vc6l                            1/1     Running             0          23m
tanzu-system-ingress         contour-78fbf6f467-lwjzf                                       1/1     Running             0          19m
tanzu-system-ingress         envoy-xqvb4                                                    2/2     Running             0          19m
tap-namespace-provisioning   controller-manager-b5bbdc5f-2vb6d                              1/1     Running             0          23m
tap-telemetry                tap-telemetry-informer-5475b68484-986rq                        1/1     Running             0          24m
tekton-pipelines-resolvers   tekton-pipelines-remote-resolvers-8cffbc5fb-pc67l              1/1     Running             0          23m
tekton-pipelines             tekton-pipelines-controller-75f5bbc94f-8gt8q                   1/1     Running             0          23m
tekton-pipelines             tekton-pipelines-webhook-799594949-z2lqr                       1/1     Running             0          23m

ClusterBuilderがREADYなことを確認します。

$ kubectl get clusterbuilder
NAME         LATESTIMAGE                                                                                                                     READY
base         ghcr.io/making/buildservice:clusterbuilder-base@sha256:b199b4eba53bd126772f144cc50ad997f5eee7fc4ed210a61397f40c8677b2d9         True
base-jammy   ghcr.io/making/buildservice:clusterbuilder-base-jammy@sha256:94182294fa45ec6395f99f36e23b0ca11552ae66ae5b29287b6c83a8507a3b3f   True
default      ghcr.io/making/buildservice:clusterbuilder-default@sha256:94182294fa45ec6395f99f36e23b0ca11552ae66ae5b29287b6c83a8507a3b3f      True

Workloadのデプロイ

TAP 1.4からはNamespace Provisionerが導入され、Workloadを作成するための事前準備が自動化されました。
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/namespace-provisioner-provision-developer-ns.html

registry-credentialsの作成と公開

tanzu secret registry add registry-credentials \
  --server ghcr.io \
  --username ${GITHUB_USERNAME} \
  --password ${GITHUB_API_TOKEN} \
  --namespace tap-install \
  --export-to-all-namespaces \
  -y

Namespaceの作成

Namespaceにapps.tanzu.vmware.com/tap-nsラベルを設定すると必要なリソースが自動生成されます。

生成されるリソースは次のドキュメントにまとまっています
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/namespace-provisioner-reference.html#default-resources-1

kubectl create ns demo
kubectl label namespaces demo apps.tanzu.vmware.com/tap-ns=""
$ kubectl get secrets,serviceaccount,rolebinding,configmap -n demo
NAME                            TYPE                             DATA   AGE
secret/registries-credentials   kubernetes.io/dockerconfigjson   1      7s

NAME                     SECRETS   AGE
serviceaccount/default   1         7s

NAME                                                               ROLE                      AGE
rolebinding.rbac.authorization.k8s.io/default-permit-deliverable   ClusterRole/deliverable   7s
rolebinding.rbac.authorization.k8s.io/default-permit-workload      ClusterRole/workload      7s

NAME                         DATA   AGE
configmap/kube-root-ca.crt   1      7s

kapp CLIを使うとNamespace Provisionerによって作成されたリソースを確認できます。

$ kapp inspect -n tap-namespace-provisioning -a provisioner.app
Target cluster 'https://127.0.0.1:56439' (nodes: kind-control-plane)

Resources in app 'provisioner.app'

Namespace  Name                        Kind            Owner  Rs  Ri  Age  
demo       default                     ServiceAccount  kapp   ok  -   21s  
^          default-permit-deliverable  RoleBinding     kapp   ok  -   21s  
^          default-permit-workload     RoleBinding     kapp   ok  -   21s  
^          registries-credentials      Secret          kapp   ok  -   21s  

Rs: Reconcile state
Ri: Reconcile information

4 resources

Succeeded

Node.jsアプリのデプロイ

tanzu apps workload apply hello-nodejs \
  --app hello-nodejs \
  --git-repo https://github.com/making/hello-nodejs \
  --git-branch master \
  --type web \
  -n demo \
  -y

ログはsternを使うとわかりやすいです。

stern -n demo hello-nodejs

Supply Chainの進捗は次のコマンドで確認できます。

$ tanzu apps workload get -n demo hello-nodejs
📡 Overview
   name:        hello-nodejs
   type:        web
   namespace:   demo

💾 Source
   type:     git
   url:      https://github.com/making/hello-nodejs
   branch:   master

📦 Supply Chain
   name:   source-to-url

   NAME               READY     HEALTHY   UPDATED   RESOURCE
   source-provider    True      True      22s       gitrepositories.source.toolkit.fluxcd.io/hello-nodejs
   image-provider     Unknown   Unknown   22s       images.kpack.io/hello-nodejs
   config-provider    False     Unknown   24s       not found
   app-config         False     Unknown   24s       not found
   service-bindings   False     Unknown   24s       not found
   api-descriptors    False     Unknown   24s       not found
   config-writer      False     Unknown   24s       not found

🚚 Delivery
   name:   delivery-basic

   NAME              READY   HEALTHY   UPDATED   RESOURCE
   source-provider   False   False     19s       imagerepositories.source.apps.tanzu.vmware.com/hello-nodejs-delivery
   deployer          False   Unknown   22s       not found

💬 Messages
   Workload [MissingValueAtPath]:   waiting to read value [.status.latestImage] from resource [images.kpack.io/hello-nodejs] in namespace [demo]
   Deliverable [HealthyConditionRule]:   Unable to resolve image with tag "ghcr.io/making/workloads/hello-nodejs-demo-bundle:8fe0ae6b-62b0-4eee-9980-ef3a021b3639" to a digest: HEAD https://ghcr.io/v2/making/workloads/hello-nodejs-demo-bundle/manifests/8fe0ae6b-62b0-4eee-9980-ef3a021b3639: unexpected status code 404 Not Found (HEAD responses have no body, use GET for details)

🛶 Pods
   NAME                             READY   STATUS     RESTARTS   AGE
   hello-nodejs-build-1-build-pod   0/1     Init:1/6   0          21s

To see logs: "tanzu apps workload tail hello-nodejs --namespace demo --timestamp --since 1h"

"Knative Services"の欄が出力され、"Ready"になればアプリでのデプロイは完了です。

$ tanzu apps workload get -n demo hello-nodejs
📡 Overview
   name:        hello-nodejs
   type:        web
   namespace:   demo

💾 Source
   type:     git
   url:      https://github.com/making/hello-nodejs
   branch:   master

📦 Supply Chain
   name:   source-to-url

   NAME               READY   HEALTHY   UPDATED   RESOURCE
   source-provider    True    True      3m30s     gitrepositories.source.toolkit.fluxcd.io/hello-nodejs
   image-provider     True    True      112s      images.kpack.io/hello-nodejs
   config-provider    True    True      99s       podintents.conventions.carto.run/hello-nodejs
   app-config         True    True      99s       configmaps/hello-nodejs
   service-bindings   True    True      99s       configmaps/hello-nodejs-with-claims
   api-descriptors    True    True      99s       configmaps/hello-nodejs-with-api-descriptors
   config-writer      True    True      37s       runnables.carto.run/hello-nodejs-config-writer

🚚 Delivery
   name:   delivery-basic

   NAME              READY   HEALTHY   UPDATED   RESOURCE
   source-provider   True    True      23s       imagerepositories.source.apps.tanzu.vmware.com/hello-nodejs-delivery
   deployer          True    True      21s       apps.kappctrl.k14s.io/hello-nodejs

💬 Messages
   No messages found.

🛶 Pods
   NAME                                             READY   STATUS      RESTARTS   AGE
   hello-nodejs-00001-deployment-66f98fc64c-bq8dx   2/2     Running     0          24s
   hello-nodejs-build-1-build-pod                   0/1     Completed   0          3m29s
   hello-nodejs-config-writer-thbcj-pod             0/1     Completed   0          97s

🚢 Knative Services
   NAME           READY   URL
   hello-nodejs   Ready   https://hello-nodejs.demo.127-0-0-1.sslip.io

To see logs: "tanzu apps workload tail hello-nodejs --namespace demo --timestamp --since 1h"
$ curl -k https://hello-nodejs.demo.127-0-0-1.sslip.io
Hello World!

確認が終わればWorkloadを削除します。

tanzu apps workload delete -n demo hello-nodejs -y

Javaアプリのデプロイ

tanzu apps workload apply spring-music \
  --app spring-music \
  --git-repo https://github.com/scottfrederick/spring-music \
  --git-branch tanzu \
  --type web \
  --annotation autoscaling.knative.dev/minScale=1 \
  -n demo \
  -y

ログはsternを使うとわかりやすいです。

stern -n demo spring-music

次のコマンドを実行し、"Knative Services"の欄が出力され、"Ready"になればアプリでのデプロイは完了です。

$ tanzu apps workload get -n demo spring-music 
📡 Overview
   name:        spring-music
   type:        web
   namespace:   demo

💾 Source
   type:     git
   url:      https://github.com/scottfrederick/spring-music
   branch:   tanzu

📦 Supply Chain
   name:   source-to-url

   NAME               READY   HEALTHY   UPDATED   RESOURCE
   source-provider    True    True      7m4s      gitrepositories.source.toolkit.fluxcd.io/spring-music
   image-provider     True    True      4m22s     images.kpack.io/spring-music
   config-provider    True    True      4m13s     podintents.conventions.carto.run/spring-music
   app-config         True    True      4m13s     configmaps/spring-music
   service-bindings   True    True      4m13s     configmaps/spring-music-with-claims
   api-descriptors    True    True      4m13s     configmaps/spring-music-with-api-descriptors
   config-writer      True    True      4m        runnables.carto.run/spring-music-config-writer

🚚 Delivery
   name:   delivery-basic

   NAME              READY   HEALTHY   UPDATED   RESOURCE
   source-provider   True    True      3m58s     imagerepositories.source.apps.tanzu.vmware.com/spring-music-delivery
   deployer          True    True      3m56s     apps.kappctrl.k14s.io/spring-music

💬 Messages
   No messages found.

🛶 Pods
   NAME                                            READY   STATUS      RESTARTS   AGE
   spring-music-00001-deployment-bdf86d97f-8rqks   2/2     Running     0          3m58s
   spring-music-build-1-build-pod                  0/1     Completed   0          7m3s
   spring-music-config-writer-v495h-pod            0/1     Completed   0          4m12s

🚢 Knative Services
   NAME           READY   URL
   spring-music   Ready   https://spring-music.demo.127-0-0-1.sslip.io

To see logs: "tanzu apps workload tail spring-music --namespace demo --timestamp --since 1h"
image

"THIS IS UNSAFE"を入力

image

TAP 1.4からはSpring Boot Actuatorに関する自動設定のデフォルトが変わりました。Spring Boot Actuatorが依存関係に含まれている場合、TAP 1.3まではデフォルトで環境変数JAVA_TOOL_OPTIONSに次のシステムプロパティが設定されていました。

  • -Dmanagement.endpoint.health.show-details="always"
  • -Dmanagement.endpoints.web.exposure.include="*"
  • -Dmanagement.server.port="8081"

TAP 1.4からはこれが自動で設定されません。次のようにJAVA_TOOL_OPTIONSを確認すると、上記のプロパティが含まれていないことがわかります。

$ kubectl get ksvc -n demo spring-music -ojsonpath='{.spec.template.spec.containers[?(@.name=="workload")].env[?(@.name=="JAVA_TOOL_OPTIONS")].value}'
-Dmanagement.endpoint.health.probes.add-additional-paths="true" -Dmanagement.health.probes.enabled="true" -Dserver.port="8080" -Dserver.shutdown.grace-period="24s"

TAP 1.4以降でもTAP 1.3以前と同様の設定を含めたい場合は、次のようにWorkloadレベルでapps.tanzu.vmware.com/auto-configure-actuatorsラベルに"true"を設定すれば良いです。

tanzu apps workload apply spring-music \
  --app spring-music \
  --git-repo https://github.com/scottfrederick/spring-music \
  --git-branch tanzu \
  --type web \
  --annotation autoscaling.knative.dev/minScale=1 \
  --label apps.tanzu.vmware.com/auto-configure-actuators=true \
  -n demo \
  -y

デプロイ完了後に設定されたJAVA_TOOL_OPTIONSを確認すると、値が変わっていることがわかります。

$ kubectl get ksvc -n demo spring-music -ojsonpath='{.spec.template.spec.containers[?(@.name=="workload")].env[?(@.name=="JAVA_TOOL_OPTIONS")].value}'
-Dmanagement.endpoint.health.probes.add-additional-paths="true" -Dmanagement.endpoint.health.show-details="always" -Dmanagement.endpoints.web.base-path="/actuator" -Dmanagement.endpoints.web.exposure.include="*" -Dmanagement.health.probes.enabled="true" -Dmanagement.server.port="8081" -Dserver.port="8080" -Dserver.shutdown.grace-period="24s"

Platformレベルで設定を反映させたい場合はtap-values.yamlに次の設定をすれば良いです。

springboot_conventions:
  autoConfigureActuators: true

Spring Boot Actuatorの設定に関するドキュメントはこちらです。 https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/spring-boot-conventions-configuring-spring-boot-actuators.html

確認が終わればWorkloadを削除します。

tanzu apps workload delete -n demo spring-music -y

GitOpsでデプロイする

https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/scc-gitops-vs-regops.html#gitops-0

まず、manifestを管理するgitレポジトリをGitHubで作成ます。READMEのみを含む https://github.com/making/hello-nodejs-manifests を作成しました。 image

image

GitレポジトリにpushするためのSecretを作成します。HTTP(S) Basic-authSSHが選べます。 ここではBasic-authを使用します。

https://github.com/settings/tokens からrepoへのアクセス権があるPersonal access tokensを生成してください。

image

このPersonal access tokenのSecetを作成し、Service AccountにこのSecretを参照させる必要があります。 TAP 1.3まではこの作業はNamepsace毎に手動またはTAP以外の仕組みで行う必要がありましたが、TAP 1.4からはNamespace Provisionerを使ってNamespace毎に自動でリソースを作成することができます。

両方のパターンを紹介します。

手動で個々にPersonal access tokenを設定 (TAP 1.3までと同じ)

まずは手動の場合。次のコマンドでSecretを作成します。

GITHUB_USERNAME=making
GITHUB_API_TOKEN=ghp_******

kubectl create secret generic git-basic -n demo \
    --type kubernetes.io/basic-auth \
    --from-literal=username=${GITHUB_USERNAME} \
    --from-literal=password=${GITHUB_API_TOKEN} \
    --dry-run=client -oyaml \
 | kubectl apply -f- 
kubectl -n demo annotate secret git-basic tekton.dev/git-0=https://github.com --overwrite=true
kubectl patch -n demo serviceaccount default -p "{\"secrets\":[{\"name\":\"git-basic\"}]}"

Namespace Provisionerを使ってPersonal access tokenを設定

Namespace ProvisionerによるGit用のSecret作成方法は次のドキュメントに記載されています。
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/namespace-provisioner-use-case3.html

追加したいリソースのテンプレートをtap-values.yamlnamespace_provisioner.additional_sourcesに記述できます。

Namespace Provisionerで追加で作成してもらいたいSecretのテンプレートは以下を使用します。
https://github.com/making/namespace-provisioner-samples/blob/main/git-basic/secret.yaml


このテンプレートに穴埋めする変数を以下のように作成します。
GITHUB_USERNAME=making
GITHUB_API_TOKEN=ghp_******

cat << EOF > workload-git-auth.yaml
apiVersion: v1
kind: Secret
metadata:
  name: workload-git-auth
  namespace: tap-install
type: Opaque
stringData:
  content.yaml: |
    git:
      host: https://github.com
      username: "${GITHUB_USERNAME}"
      token: "${GITHUB_API_TOKEN}"
EOF

kubectl apply -f workload-git-auth.yaml

デフォルトで作成されるリソース(ServiceAccount)を変更し、secretsgit-basicを追加するためのoverlayファイルを作成します。

cat << EOF > workload-git-auth-overlay.yaml
apiVersion: v1
kind: Secret
metadata:
  name: workload-git-auth-overlay
  namespace: tap-install
  annotations:
    kapp.k14s.io/change-rule: "delete after deleting tap"
stringData:
  workload-git-auth-overlay.yaml: |
    #@ load("@ytt:overlay", "overlay")
    #@overlay/match by=overlay.subset({"kind": "ServiceAccount","metadata":{"name":"default"}}), expects="0+"
    ---
    secrets:
    #@overlay/append
    - name: git-basic
EOF

kubectl apply -f workload-git-auth-overlay.yaml

次のようにtap-values.yamlnamespace_provisionerの設定を追記します。

cat <<EOF >> tap-values.yaml

namespace_provisioner:
  controller: true
  additional_sources:
  - git:
      url: https://github.com/making/namespace-provisioner-samples.git
      ref: origin/main
      subPath: git-basic
    path: _ytt_lib/git-basic
  import_data_values_secrets:
  - name: workload-git-auth
    namespace: tap-install
    create_export: true
  overlay_secrets:
  - name: workload-git-auth-overlay
    namespace: tap-install
    create_export: true
EOF

⚠️ TAP 1.4ではadditional_sources以下にinlineの設定ができましたが、1.5.0ではgit以外が設定されるとエラーにでるようになっていました。バリデーションと言うよりもgit以外が設定されることが想定されていないようです。

次のコマンドでTAPをアップデートすれば、apps.tanzu.vmware.com/tap-nsラベルのついた全てのNamespaceにgit-basicというSecretが作成され、default Service Accountのsecretsgit-basicが追加されます。

tanzu package installed update -n tap-install tap --values-file tap-values.yaml

kapp CLIでリソースを確認すると

$ kapp inspect -n tap-namespace-provisioning -a provisioner.app                  
Target cluster 'https://127.0.0.1:56439' (nodes: kind-control-plane)

Resources in app 'provisioner.app'

Namespace  Name                        Kind            Owner  Rs  Ri  Age  
demo       default                     ServiceAccount  kapp   ok  -   2m  
^          default-permit-deliverable  RoleBinding     kapp   ok  -   2m  
^          default-permit-workload     RoleBinding     kapp   ok  -   2m  
^          git-basic                   Secret          kapp   ok  -   21s  
^          registries-credentials      Secret          kapp   ok  -   2m  

Rs: Reconcile state
Ri: Reconcile information

5 resources

Succeeded

default Service Accountを確認すると

$ kubectl get sa -n demo default -oyaml
apiVersion: v1
imagePullSecrets:
- name: registries-credentials
kind: ServiceAccount
metadata:
# ...
secrets:
- name: registries-credentials
- name: git-basic

反映が遅い場合はkctrl CLIで次のように強制的に反映できます。どちらか一方だけで良いかもしれません。

# tap-values.yamlの変更を反映し、Namespace Provisionerを更新
kctrl app kick -n tap-install -a namespace-provisioner -y

# Namespace Provisionerの変更を反映し、作成するリソースを更新
kctrl app kick -n tap-namespace-provisioning -a provisioner -y

Workloadのデプロイ

Personal access tokenの設定が終われば、次のコマンドでデプロイできます。

tanzu apps workload apply hello-nodejs \
  --app hello-nodejs \
  --git-repo https://github.com/making/hello-nodejs \
  --git-branch master \
  --type web \
  --param gitops_branch=main \
  --param gitops_commit_message=Bump \
  --param gitops_server_address=https://github.com \
  --param gitops_repository_owner=making \
  --param gitops_repository_name=tap-gitops-manifests \
  --param gitops_user_email=makingx+bot@gmail.com \
  --param gitops_user_name=making-bot \
  --param gitops_ssh_secret=git-basic \
  -n demo \
  -y

ログはsternを使うとわかりやすいです。

stern -n demo hello-nodejs

次のコマンドを実行し、"Knative Services"の欄が出力され、"Ready"になればアプリでのデプロイは完了です。

$ tanzu apps workload get hello-nodejs -n demo

kpackによるコンテナイメージのビルドが終わると、そのイメージのdigestを使用してmanifestをgit commit & pushがTektonによって行われます。 gitレポジトリを見ると次のコミットが自動で行われていることがわかります。

image

URLにアクセスします。

$ curl -k https://hello-demo.127-0-0-1.sslip.io
Hello World!

ソースコードを変更してgit pushすると、新しいコンテナイメージがビルドされ、manifestも新しいイメージのdigestを使用するようにcommit & pushされます。 次のようなコミットになります。

image

GitOpsでpull requestを使用する

TAP 1.2からはmanifestの変更を直接commit & pushする代わり、pull requestを送ることができるようになりました。

https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.4/tap/scc-gitops-vs-regops.html#pull-requests-2

tap-values.yamlの以下の行を追加します。デフォルトはdirectです。

# ...
ootb_supply_chain_basic:
  gitops:
    commit_strategy: pull_request
    pull_request:
      server_kind: github
      commit_branch: ""
      pull_request_title: "ready for review"
      pull_request_body: "generated by supply chain"

次のコマンドでTAPをアップデートします。

tanzu package installed update -n tap-install tap -f tap-values.yaml

ソースコードに変更を加え、git pushすると、コンテナイメージ作成後に次のようなPull Requestが作成されます。

image image

このPull Requestをマージすると、変更結果がデプロイされます。

確認が終わればWorkloadを削除します。

tanzu apps workload delete -n demo hello -y

Service ToolkitによるServiceインスタンスの動的プロビジョニング

TAP 1.5からService ToolkitによるServiceインスタンスの動的プロビジョニングがサポートされました。ドキュメントは↓
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/services-toolkit-tutorials-setup-dynamic-provisioning.html

TAP 1.3まではService Bindingに対応するServiceインスタンスのリソース(PostgresリソースRabbitmqCluster、Secretなど)を参照するResourceClaimリソースを手動で作成して、WorkloadにBindしていました。 Persistent Volumeのアナロジーで言うと、これまではPersistentVolmeリソース (Serviceのインスタンスに相当) を管理者が手動で事前に作成し、開発者がPersistentVolumeClaimリソース (ResourceClaimに相当) を作成することでPersistentVolmeの利用が確定するようなフローが必要でした。
TAP 1.4からはStorageClassのようなClusterInstanceClassを指定可能なClassClaimがResourceClaimにの代わりに利用可能になりましたが、Dynamic Provisionerのサポートがなかったので、依然としてServiceインスタンスのリソースは手動で行う必要がありました。
TAP 1.5でようやくDynamic Provisionerがサポートされました。実装にはCrossplaneが利用されています。
これにより、Dynamic ProvisionerをサポートしたSClusterInstanceClassを使用する場合、Serviceインスタンスを事前に作成しなくても、ClassClaimを作成するだけで動的にServiceインスタンスが作成されます。

Cloud Foundryのアナロジーで言うと、これまではService Bindingによる cf bind-service に相当する機能はサポートされていましたが、サービスインスタンスは cf create-user-provided-service のような形で作成する必要がありました。TAP 1.5からは cf create-service に相当する機能がサポートされたことになります。

TAP 1.5ではpre-installedなDynamic ProvisionerとしてBitnami Servicesが利用可能です。チュートリアルは↓
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/services-toolkit-tutorials-working-with-bitnami-services.html

BitnamiのHelm Chartを使ったサービスインスタンスの動的な作成が可能です。MySQL、PostgreSQL、RabbitMQ、Redisがサポートされています。

サポートされているClusterInstanceClass一覧は次のコマンドで確認できます。

$ tanzu service classes list 
  NAME                  DESCRIPTION            
  mysql-unmanaged       MySQL by Bitnami       
  postgresql-unmanaged  PostgreSQL by Bitnami  
  rabbitmq-unmanaged    RabbitMQ by Bitnami    
  redis-unmanaged       Redis by Bitnami 

あるいはkubectlでも確認できます。

$ kubectl get clusterinstanceclass
NAME                   DESCRIPTION             READY   REASON
mysql-unmanaged        MySQL by Bitnami        True    Ready
postgresql-unmanaged   PostgreSQL by Bitnami   True    Ready
rabbitmq-unmanaged     RabbitMQ by Bitnami     True    Ready
redis-unmanaged        Redis by Bitnami        True    Ready

kubectl get storageclass あるいは cf marketplaceに相当

では、このDynamic Provisionerを使ってこのBlogのAPI (https://github.com/categolj/blog-api) をデプロイしてみましょう。次のコマンドでPostgreSQLのClassClaimを作成します。

tanzu service class-claim create blog-db --class postgresql-unmanaged --parameter storageGB=3 -n demo

--parameterで指定可能なパラメータは https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/bitnami-services-reference-package-values.html に記載されています。

次のコマンドで作成のStatusを確認できます。ReadyTrueになっていればPostgreSQLのインスタンスが利用可能です。

$ tanzu services class-claims get blog-db --namespace demo
Name: blog-db
Namespace: demo
Claim Reference: services.apps.tanzu.vmware.com/v1alpha1:ClassClaim:blog-db
Class Reference: 
  Name: postgresql-unmanaged
Parameters: 
  storageGB: 3
Status: 
  Ready: True
  Claimed Resource: 
    Name: 7c801387-1242-4403-a9b6-46a627cfeb89
    Namespace: demo
    Group: 
    Version: v1
    Kind: Secre

kubectlでも確認できます。

$ kubectl get classclaim -n demo                            
NAME      READY   REASON   CLASSREF
blog-db   True    Ready    postgresql-unmanaged

このPostgreSQLへの接続情報を含むSecret名は次のコマンドで確認できます。

$ kubectl get classclaim -n demo blog-db -ojsonpath='{.status.binding.name}'
7c801387-1242-4403-a9b6-46a627cfeb89

作成されたSecretを見てみましょう。

$ kubectl get secret -n demo 7c801387-1242-4403-a9b6-46a627cfeb89 -ojson | jq '.data | map_values(@base64d)'
{
  "database": "blog-db-klh86",
  "host": "10.96.237.195",
  "password": "7x71VaBeNxuQ0Bc5DAWJFMpxhXYvD30c",
  "port": "5432",
  "provider": "bitnami",
  "type": "postgresql",
  "username": "postgres"
}

PostgreSQLの実体はdemo namespaceにはありません。namespace名は次のコマンドで確認できます。

$ kubectl get xpostgresqlinstances
NAME            SYNCED   READY   COMPOSITION                                              AGE
blog-db-klh86   True     True    xpostgresqlinstances.bitnami.database.tanzu.vmware.com   3m32s

実体を確認します。

$ kubectl get statefulset -n blog-db-klh86
NAME            READY   AGE
blog-db-klh86   1/1     8m57s

このPostgreSQLをBindして https://github.com/categolj/blog-api のWorkloadを作成します。--service-ref blog-db=の値にはtanzu services class-claims getの出力結果のClaim Referenceを指定してください。

tanzu apps workload apply blog-api \
  --app blog-api \
  --git-repo https://github.com/categolj/blog-api \
  --git-branch main \
  --type web \
  --annotation autoscaling.knative.dev/minScale=1 \
  --service-ref blog-db=services.apps.tanzu.vmware.com/v1alpha1:ClassClaim:blog-db \
  --build-env BP_JVM_VERSION=17 \
  --env logging.level.io.opentelemetry.exporter.zipkin.ZipkinSpanExporter=ERROR \
  -n demo \
  -y

ログはsternを使うとわかりやすいです。

stern -n demo blog-api

次のコマンドを実行し、"Knative Services"の欄が出力され、"Ready"になればアプリでのデプロイは完了です。

$ tanzu apps workload get blog-api --namespace demo
📡 Overview
   name:        blog-api
   type:        web
   namespace:   demo

💾 Source
   type:     git
   url:      https://github.com/categolj/blog-api
   branch:   main

📦 Supply Chain
   name:   source-to-url

   NAME               READY   HEALTHY   UPDATED   RESOURCE
   source-provider    True    True      15m       gitrepositories.source.toolkit.fluxcd.io/blog-api
   image-provider     True    True      6m26s     images.kpack.io/blog-api
   config-provider    True    True      6m18s     podintents.conventions.carto.run/blog-api
   app-config         True    True      6m18s     configmaps/blog-api
   service-bindings   True    True      6m18s     configmaps/blog-api-with-claims
   api-descriptors    True    True      6m18s     configmaps/blog-api-with-api-descriptors
   config-writer      True    True      6m5s      runnables.carto.run/blog-api-config-writer

🚚 Delivery
   name:   delivery-basic

   NAME              READY   HEALTHY   UPDATED   RESOURCE
   source-provider   True    True      5m6s      imagerepositories.source.apps.tanzu.vmware.com/blog-api-delivery
   deployer          True    True      5m1s      apps.kappctrl.k14s.io/blog-api

💬 Messages
   No messages found.

🔁 Services
   CLAIM     NAME      KIND         API VERSION
   blog-db   blog-db   ClassClaim   services.apps.tanzu.vmware.com/v1alpha1

🛶 Pods
   NAME                                        READY   STATUS      RESTARTS   AGE
   blog-api-00001-deployment-d67df5595-k6ph5   2/2     Running     0          5m2s
   blog-api-build-1-build-pod                  0/1     Completed   0          15m
   blog-api-config-writer-vpw85-pod            0/1     Completed   0          6m16s

🚢 Knative Services
   NAME       READY   URL
   blog-api   Ready   https://blog-api.demo.127-0-0-1.sslip.io

デプロイされたアプリにアクセスし、Blogに記事を投稿します。

curl -sk https://blog-api.demo.127-0-0-1.sslip.io/entries/template.md > template.md
curl -sk -u admin:changeme -XPUT https://blog-api.demo.127-0-0-1.sslip.io/entries/1 -H "Content-Type: text/markdown" -d "$(cat template.md)"

登録したデータが返却されることで、PostgreSQLにアクセスできていることがわかります。

$ curl -sk https://blog-api.demo.127-0-0-1.sslip.io/entries/1 | jq .
{
  "entryId": 1,
  "frontMatter": {
    "title": "Welcome to CategolJ!",
    "categories": [
      {
        "name": "Blog"
      },
      {
        "name": "Posts"
      },
      {
        "name": "Templates"
      }
    ],
    "tags": [
      {
        "name": "CategolJ"
      },
      {
        "name": "Hello World"
      }
    ]
  },
  "content": "Welcome\n\n**Hello world**, this is my first Categolj blog post.\n\nI hope you like it!",
  "created": {
    "name": "admin",
    "date": "2023-04-12T01:56:13.80122Z"
  },
  "updated": {
    "name": "admin",
    "date": "2023-04-12T01:56:13.80122Z"
  }
}

Bitnami Servicesはインストールしてすぐに使えるので便利ですが、おそらくProductionで使われることは想定されていないので、 例えばMulti Cluster構成において、ProductionのRunクラスタでは同じClassClaim名だけれど、実体はBitnami Servicesとは別のServiceを参照すると言う使い方になるのではないでしょうか。
Production向けには手動で作成したサービスをClassClaimで参照させるか、自分でDynamic Provisionerを作成することが考えられます。
Dynamic Provisionerの追加方法は以下のドキュメントを参照してください。

ProvisionerベースのClassClaimの作成はデフォルトではcluster-admin clusterroleを持つユーザーにのみ許可されています。Bitnami Servicesは例外で app-operator clusterroleを持つユーザーにも許可されています。RBACを変更する場合は以下のドキュメントを参照してください。
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.5/tap/services-toolkit-how-to-guides-authorize-claim-provisioner-classes.html


TAP 1.5を試しました。TAP 1.5には他にもたくさんの新機能があるので追々紹介したいと思います。


✒️️ Edit  ⏰ History  🗑 Delete