Tanzu Application Platform 1.4 をKindにインストールします。
Intel版のMacで試しています。
本記事ではTAPをInstallし、"Hello World"なアプリケーションをソースコードからデプロイする機能("Source to URL")を試します。
TAP 1.3までと違い、TAP 1.4ではデフォルトでHTTPSが有効になりました。以下のこれまでのインストールメモとは違い、ytt overlaysによるカスタマイズは不要になりました。
- Tanzu Application Platform 1.3 (Iterate Profile) をKindにインストールしHTTPSを有効にするメモ
- Tanzu Application Platform 1.2 (Iterate Profile) をKindにインストールしHTTPSを有効にするメモ
- Tanzu Application Platform 1.1 (Iterate Profile) をKindにインストールしHTTPSを有効にするメモ
目次
- Kindクラスタの作成
- Pivnet CLIのインストール
- EULAの承諾
- Tanzu CLIのインストール
- Cluster Essentials for VMware Tanzuのインストール
- Tanzu Application Platformのインストール
- Workloadのデプロイ
- GitOpsでデプロイする
- GitOpsでpull requestを使用する
- Kaniko経由でDockerfileを使う
Kindクラスタの作成
Dockerには4 CPU, 4 GBメモリ以上を割り当ててください。
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.25.8
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>
EULAの承諾
初めてインストールする場合は、以下のコンポーネントのEULAをAcceptしてください。
⚠️ EULAで定められている使用期間は30日間です。とは言え、特にソフトウェア的に制限がかけられているわけではありません。
Tanzu CLIのインストール
# For Mac
pivnet download-product-files --product-slug='tanzu-application-platform' --release-version='1.4.2' --glob='tanzu-framework-darwin-amd64-*.tar'
# For Linux
pivnet download-product-files --product-slug='tanzu-application-platform' --release-version='1.4.2' --glob='tanzu-framework-linux-amd64-*.tar'
# For Windows
pivnet download-product-files --product-slug='tanzu-application-platform' --release-version='1.4.2' --glob='tanzu-framework-windows-amd64-*.zip'
tar xvf tanzu-framework-*-amd64-*.tar
install cli/core/v0.25.4/tanzu-core-*_amd64 /usr/local/bin/tanzu
export TANZU_CLI_NO_INIT=true
$ tanzu version
version: v0.25.4
buildDate: 2022-12-22
sha: 8204f5b0d-dirty
プラグインのインストール
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.4.1' --glob='tanzu-cluster-essentials-darwin-amd64-*'
# Linux
pivnet download-product-files --product-slug='tanzu-cluster-essentials' --release-version='1.4.1' --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.4.1
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-b95b87ff9-226pb 2/2 Running 0 74s
$ kubectl get pod -n secretgen-controller
NAME READY STATUS RESTARTS AGE
secretgen-controller-9c7675fc5-ml9ft 1/1 Running 0 57s
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 \
--url registry.tanzu.vmware.com/tanzu-application-platform/tap-packages:1.4.2 \
--namespace tap-install
$ tanzu package available list --namespace tap-install
NAME DISPLAY-NAME SHORT-DESCRIPTION LATEST-VERSION
accelerator.apps.tanzu.vmware.com Application Accelerator for VMware Tanzu Used to create new projects and configurations. 1.4.2
api-portal.tanzu.vmware.com API portal A unified user interface for API discovery and exploration at scale. 1.2.10
apis.apps.tanzu.vmware.com API Auto Registration for VMware Tanzu A TAP component to automatically register API exposing workloads as API entities 0.2.4
in TAP GUI.
backend.appliveview.tanzu.vmware.com Application Live View for VMware Tanzu App for monitoring and troubleshooting running apps 1.4.2
buildservice.tanzu.vmware.com Tanzu Build Service Tanzu Build Service enables the building and automation of containerized 1.9.5
software workflows securely and at scale.
carbonblack.scanning.apps.tanzu.vmware.com VMware Carbon Black for Supply Chain Security Tools - Scan Default scan templates using VMware Carbon Black 1.1.0-beta.1
cartographer.tanzu.vmware.com Cartographer Kubernetes native Supply Chain Choreographer. 0.6.5
cnrs.tanzu.vmware.com Cloud Native Runtimes Cloud Native Runtimes is a serverless runtime based on Knative 2.1.2
connector.appliveview.tanzu.vmware.com Application Live View Connector for VMware Tanzu App for discovering and registering running apps 1.4.2
controller.conventions.apps.tanzu.vmware.com Convention Service for VMware Tanzu Convention Service enables app operators to consistently apply desired runtime 0.8.3
configurations to fleets of workloads.
controller.source.apps.tanzu.vmware.com Tanzu Source Controller Tanzu Source Controller enables workload create/update from source code. 0.6.2
conventions.appliveview.tanzu.vmware.com Application Live View Conventions for VMware Tanzu Application Live View convention server 1.4.2
developer-conventions.tanzu.vmware.com Tanzu App Platform Developer Conventions Developer Conventions 0.9.1
eventing.tanzu.vmware.com Eventing Eventing is an event-driven architecture platform based on Knative Eventing 2.1.2
external-secrets.apps.tanzu.vmware.com External Secrets Operator External Secrets Operator is a Kubernetes operator that integrates external 0.6.1+tap.4
secret management systems.
fluxcd.source.controller.tanzu.vmware.com Flux Source Controller The source-controller is a Kubernetes operator, specialised in artifacts 0.27.0+tap.8
acquisition from external sources such as Git, Helm repositories and S3 buckets.
grype.scanning.apps.tanzu.vmware.com Grype for Supply Chain Security Tools - Scan Default scan templates using Anchore Grype 1.4.0
learningcenter.tanzu.vmware.com Learning Center for Tanzu Application Platform Guided technical workshops 0.2.6
metadata-store.apps.tanzu.vmware.com Supply Chain Security Tools - Store Post SBoMs and query for image, package, and vulnerability metadata. 1.4.4
namespace-provisioner.apps.tanzu.vmware.com Namespace Provisioner Automatic Provisioning of Developer Namespaces. 0.1.4
ootb-delivery-basic.tanzu.vmware.com Tanzu App Platform Out of The Box Delivery Basic Out of The Box Delivery Basic. 0.11.2
ootb-supply-chain-basic.tanzu.vmware.com Tanzu App Platform Out of The Box Supply Chain Basic Out of The Box Supply Chain Basic. 0.11.2
ootb-supply-chain-testing-scanning.tanzu.vmware.com Tanzu App Platform Out of The Box Supply Chain with Testing and Scanning Out of The Box Supply Chain with Testing and Scanning. 0.11.2
ootb-supply-chain-testing.tanzu.vmware.com Tanzu App Platform Out of The Box Supply Chain with Testing Out of The Box Supply Chain with Testing. 0.11.2
ootb-templates.tanzu.vmware.com Tanzu App Platform Out of The Box Templates Out of The Box Templates. 0.11.2
policy.apps.tanzu.vmware.com Supply Chain Security Tools - Policy Controller Policy Controller enables defining of a policy to restrict unsigned container 1.2.1
images.
scanning.apps.tanzu.vmware.com Supply Chain Security Tools - Scan Scan for vulnerabilities and enforce policies directly within Kubernetes native 1.4.0
Supply Chains.
service-bindings.labs.vmware.com Service Bindings for Kubernetes Service Bindings for Kubernetes implements the Service Binding Specification. 0.9.1
services-toolkit.tanzu.vmware.com Services Toolkit The Services Toolkit enables the management, lifecycle, discoverability and 0.9.2
connectivity of Service Resources (databases, message queues, DNS records,
etc.).
snyk.scanning.apps.tanzu.vmware.com Snyk for Supply Chain Security Tools - Scan Default scan templates using Snyk 1.0.0-beta.6
spring-boot-conventions.tanzu.vmware.com Tanzu Spring Boot Conventions Server Default Spring Boot convention server. 1.4.2
sso.apps.tanzu.vmware.com AppSSO Application Single Sign-On for Tanzu 3.0.1
tap-auth.tanzu.vmware.com Default roles for Tanzu Application Platform Default roles for Tanzu Application Platform 1.1.0
tap-gui.tanzu.vmware.com Tanzu Application Platform GUI web app graphical user interface for Tanzu Application Platform 1.4.6
tap-telemetry.tanzu.vmware.com Telemetry Collector for Tanzu Application Platform Tanzu Application Plaform Telemetry 0.4.1-build.2
tap.tanzu.vmware.com Tanzu Application Platform Package to install a set of TAP components to get you started based on your use 1.4.2
case.
tekton.tanzu.vmware.com Tekton Pipelines Tekton Pipelines is a framework for creating CI/CD systems. 0.41.0+tap.7
workshops.learningcenter.tanzu.vmware.com Workshop Building Tutorial Workshop Building Tutorial 0.2.5
Iterate Profileのインストール
iterate profileをインストールするために、次のtap-values.yaml
を作成します。
4CPUでもインストールできるように不要なpackageをexcluded_packages
に追加しています。
GITHUB_USERNAME=...
GITHUB_API_TOKEN=...
cat <<EOF > tap-values.yaml
shared:
ingress_domain: 127-0-0-1.sslip.io
image_registry:
project_path: ghcr.io/${GITHUB_USERNAME}
username: ${GITHUB_USERNAME}
password: ${GITHUB_API_TOKEN}
ceip_policy_disclosed: true
profile: iterate
supply_chain: basic
contour:
contour:
replicas: 1
envoy:
service:
type: NodePort
nodePorts:
http: 31080
https: 31443
hostPorts:
enable: true
cnrs:
provider: local
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.io
は127.0.0.1
に解決されます。
TAPをインストールします。
tanzu package install tap \
-p tap.tanzu.vmware.com \
-v 1.4.2 \
--values-file tap-values.yaml \
-n tap-install \
--wait=false
インストールの進捗は次のコマンドで確認します。
while [ "$(kubectl -n tap-install get app tap -o=jsonpath='{.status.friendlyDescription}')" != "Reconcile succeeded" ];do
date
kubectl get app -n tap-install
echo "---------------------------------------------------------------------"
sleep 10
done
echo "✅ Install succeeded"
全てのappが Reconcile succeeded
になるまで待ちます。10分くらいかかります。
$ kubectl get app -n tap-install
NAME DESCRIPTION SINCE-DEPLOY AGE
api-auto-registration Reconcile succeeded 8m43s 8m50s
appliveview-connector Reconcile succeeded 8m45s 8m52s
appliveview-conventions Reconcile succeeded 4m16s 4m23s
buildservice Reconcile succeeded 8m44s 8m51s
cartographer Reconcile succeeded 4m51s 4m58s
cert-manager Reconcile succeeded 8m43s 8m51s
cnrs Reconcile succeeded 2m15s 2m22s
contour Reconcile succeeded 4m52s 4m58s
conventions-controller Reconcile succeeded 4m51s 4m58s
developer-conventions Reconcile succeeded 4m16s 4m23s
fluxcd-source-controller Reconcile succeeded 8m42s 8m50s
namespace-provisioner Reconcile succeeded 8m37s 8m50s
ootb-delivery-basic Reconcile succeeded 3m5s 3m12s
ootb-supply-chain-basic Reconcile succeeded 3m6s 3m12s
ootb-templates Reconcile succeeded 3m14s 3m20s
service-bindings Reconcile succeeded 8m45s 8m52s
services-toolkit Reconcile succeeded 4m52s 4m58s
source-controller Reconcile succeeded 4m53s 4m59s
spring-boot-conventions Reconcile succeeded 4m16s 4m23s
tap Reconcile succeeded 8m52s 8m59s
tap-auth Reconcile succeeded 8m45s 8m52s
tap-telemetry Reconcile succeeded 8m44s 8m51s
tekton-pipelines Reconcile succeeded 8m45s 8m52s
インストールされたパッケージは次の通りです。
$ tanzu package installed list -n tap-install
NAME PACKAGE-NAME PACKAGE-VERSION STATUS
api-auto-registration apis.apps.tanzu.vmware.com 0.2.4 Reconcile succeeded
appliveview-connector connector.appliveview.tanzu.vmware.com 1.4.2 Reconcile succeeded
appliveview-conventions conventions.appliveview.tanzu.vmware.com 1.4.2 Reconcile succeeded
buildservice buildservice.tanzu.vmware.com 1.9.5 Reconcile succeeded
cartographer cartographer.tanzu.vmware.com 0.6.5 Reconcile succeeded
cert-manager cert-manager.tanzu.vmware.com 2.3.0 Reconcile succeeded
cnrs cnrs.tanzu.vmware.com 2.1.2 Reconcile succeeded
contour contour.tanzu.vmware.com 1.22.3+tap.2 Reconcile succeeded
conventions-controller controller.conventions.apps.tanzu.vmware.com 0.8.3 Reconcile succeeded
developer-conventions developer-conventions.tanzu.vmware.com 0.9.1 Reconcile succeeded
fluxcd-source-controller fluxcd.source.controller.tanzu.vmware.com 0.27.0+tap.8 Reconcile succeeded
namespace-provisioner namespace-provisioner.apps.tanzu.vmware.com 0.1.4 Reconcile succeeded
ootb-delivery-basic ootb-delivery-basic.tanzu.vmware.com 0.11.2 Reconcile succeeded
ootb-supply-chain-basic ootb-supply-chain-basic.tanzu.vmware.com 0.11.2 Reconcile succeeded
ootb-templates ootb-templates.tanzu.vmware.com 0.11.2 Reconcile succeeded
service-bindings service-bindings.labs.vmware.com 0.9.1 Reconcile succeeded
services-toolkit services-toolkit.tanzu.vmware.com 0.9.2 Reconcile succeeded
source-controller controller.source.apps.tanzu.vmware.com 0.6.2 Reconcile succeeded
spring-boot-conventions spring-boot-conventions.tanzu.vmware.com 1.4.2 Reconcile succeeded
tap tap.tanzu.vmware.com 1.4.2 Reconcile succeeded
tap-auth tap-auth.tanzu.vmware.com 1.1.0 Reconcile succeeded
tap-telemetry tap-telemetry.tanzu.vmware.com 0.4.1-build.2 Reconcile succeeded
tekton-pipelines tekton.tanzu.vmware.com 0.41.0+tap.7 Reconcile succeeded
デプロイされたPodは次の通りです。
$ kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
api-auto-registration api-auto-registration-controller-c87c7f8dd-djpnj 1/1 Running 0 8m54s
app-live-view-connector application-live-view-connector-blpxw 1/1 Running 0 8m58s
app-live-view-conventions appliveview-webhook-f9b5dcc6-vzvdc 1/1 Running 0 4m29s
build-service build-pod-image-fetcher-7whw5 5/5 Running 0 8m51s
build-service dependency-updater-controller-668c5568bd-fbf7l 1/1 Running 0 8m51s
build-service secret-syncer-controller-56978c9fd4-qm8wp 1/1 Running 0 8m51s
build-service warmer-controller-b7d4697d-d58dl 1/1 Running 0 8m51s
cartographer-system cartographer-controller-6b5d895476-cd99z 1/1 Running 0 4m58s
cartographer-system cartographer-conventions-controller-manager-6574b57bcc-6txtd 1/1 Running 0 4m58s
cert-injection-webhook cert-injection-webhook-9fcc5884-q8rgx 1/1 Running 0 8m51s
cert-manager cert-manager-6589fc4bd4-dfp89 1/1 Running 0 8m33s
cert-manager cert-manager-cainjector-5bb7fb97c5-gxc8h 1/1 Running 0 8m33s
cert-manager cert-manager-webhook-7b9b65ccc7-rm2nt 1/1 Running 0 8m33s
conventions-system conventions-controller-manager-599f48fc6d-7kwt7 1/1 Running 0 5m
developer-conventions webhook-758bb7f76f-8mk4b 1/1 Running 0 4m28s
flux-system fluxcd-source-controller-869f675c46-z28k9 1/1 Running 0 8m53s
kapp-controller kapp-controller-b95b87ff9-226pb 2/2 Running 0 3h59m
knative-serving activator-68b67d68c9-xxfn4 1/1 Running 0 2m23s
knative-serving autoscaler-6f7ddbc75c-qw57c 1/1 Running 0 2m24s
knative-serving autoscaler-hpa-7c88f7ddb8-qbts9 1/1 Running 0 2m22s
knative-serving controller-84cc778bd9-86vsm 1/1 Running 0 2m23s
knative-serving domain-mapping-6d576cbd5d-88ghb 1/1 Running 0 2m24s
knative-serving domainmapping-webhook-7974ffb568-sxwdx 1/1 Running 0 2m24s
knative-serving net-certmanager-controller-76f677575f-2v685 1/1 Running 0 2m24s
knative-serving net-certmanager-webhook-6df78bf5cb-76dd8 1/1 Running 0 2m23s
knative-serving net-contour-controller-698bcbc897-bwcv2 1/1 Running 0 2m22s
knative-serving webhook-755d6bbc8f-2v2rn 1/1 Running 0 2m24s
kpack kpack-controller-779444dd66-rlfc7 1/1 Running 0 8m51s
kpack kpack-webhook-668df79bcf-l4g42 1/1 Running 0 8m51s
kube-system coredns-6d4b75cb6d-c8kzt 1/1 Running 0 3h59m
kube-system coredns-6d4b75cb6d-lkwx9 1/1 Running 0 3h59m
kube-system etcd-kind-control-plane 1/1 Running 0 3h59m
kube-system kindnet-9c8q2 1/1 Running 0 3h59m
kube-system kube-apiserver-kind-control-plane 1/1 Running 0 3h59m
kube-system kube-controller-manager-kind-control-plane 1/1 Running 0 3h59m
kube-system kube-proxy-8z4dg 1/1 Running 0 3h59m
kube-system kube-scheduler-kind-control-plane 1/1 Running 0 3h59m
local-path-storage local-path-provisioner-6b84c5c67f-7j29z 1/1 Running 0 3h59m
secretgen-controller secretgen-controller-9c7675fc5-ml9ft 1/1 Running 0 3h58m
service-bindings manager-df7db75db-7hvsz 1/1 Running 0 8m56s
services-toolkit resource-claims-apiserver-65857c7c89-cjbtq 1/1 Running 0 5m
services-toolkit services-toolkit-controller-manager-55b678b79b-rsjq9 1/1 Running 0 5m
source-system source-controller-manager-6c55456d9d-zt9pr 1/1 Running 0 5m4s
spring-boot-convention spring-boot-webhook-5498b46547-lb9t8 1/1 Running 0 4m19s
stacks-operator-system controller-manager-5977495d45-z7ktl 1/1 Running 0 8m51s
tanzu-system-ingress contour-ff5fb85cf-xfgvt 1/1 Running 0 5m1s
tanzu-system-ingress envoy-h2fkh 2/2 Running 0 5m1s
tap-namespace-provisioning controller-manager-76ddf69dfd-zcdrt 1/1 Running 0 8m49s
tap-telemetry tap-telemetry-informer-cf79497bd-ggdv9 1/1 Running 0 8m57s
tekton-pipelines-resolvers tekton-pipelines-remote-resolvers-554cf9665f-92977 1/1 Running 0 8m55s
tekton-pipelines tekton-pipelines-controller-6d757897f7-v2ldc 1/1 Running 0 8m55s
tekton-pipelines tekton-pipelines-webhook-58d8d4884d-nxb5z 1/1 Running 0 8m55s
ClusterBuilderがREADYなことを確認します。
$ kubectl get clusterbuilder
NAME LATESTIMAGE READY
base ghcr.io/making/buildservice:clusterbuilder-base@sha256:d0a5289c4a3ad54f99e1131d4aa39870d41b1c591ecf803ceb0a8055c6cef89b True
base-jammy ghcr.io/making/buildservice:clusterbuilder-base-jammy@sha256:656903e769390d69bf4efb1d189f0b7d21e4eebc6a3754a97e5b075aaa428567 True
default ghcr.io/making/buildservice:clusterbuilder-default@sha256:d0a5289c4a3ad54f99e1131d4aa39870d41b1c591ecf803ceb0a8055c6cef89b True
Workloadのデプロイ
TAP 1.4からはNamespace Provisionerが導入され、Workloadを作成するための事前準備が自動化されました。
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
1.3までと違って、--export-to-all-namespaces
で全namespaceに公開します。
namespace個別でcredentialsを変える必要がある場合は、namespace毎にtanzu secret registry
を実施する必要があります。
Namespaceの作成
Namespaceにapps.tanzu.vmware.com/tap-ns
ラベルを設定すると必要なリソースが自動生成されます。
生成されるリソースは次のドキュメントにまとまっています
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.4/tap/namespace-provisioner-reference.html#default-resources-mapping
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 26s
NAME SECRETS AGE
serviceaccount/default 1 27s
NAME ROLE AGE
rolebinding.rbac.authorization.k8s.io/default-permit-deliverable ClusterRole/deliverable 26s
rolebinding.rbac.authorization.k8s.io/default-permit-workload ClusterRole/workload 26s
NAME DATA AGE
configmap/kube-root-ca.crt 1 27s
kapp
CLIを使うとNamespace Provisionerによって作成されたリソースを確認できます。
$ kapp inspect -n tap-namespace-provisioning -a provisioner.app
Target cluster 'https://127.0.0.1:57671' (nodes: kind-control-plane)
Resources in app 'provisioner.app'
Namespace Name Kind Owner Rs Ri Age
demo default ServiceAccount kapp ok - 1h
^ default-permit-deliverable RoleBinding kapp ok - 1h
^ default-permit-workload RoleBinding kapp ok - 1h
^ registries-credentials Secret kapp ok - 1h
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 15s gitrepositories.source.toolkit.fluxcd.io/hello-nodejs
image-provider Unknown Unknown 15s images.kpack.io/hello-nodejs
config-provider False Unknown 18s not found
app-config False Unknown 18s not found
service-bindings False Unknown 18s not found
api-descriptors False Unknown 18s not found
config-writer False Unknown 18s not found
🚚 Delivery
name: delivery-basic
NAME READY HEALTHY UPDATED RESOURCE
source-provider False False 13s imagerepositories.source.apps.tanzu.vmware.com/hello-nodejs-delivery
deployer False Unknown 15s 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:9839ebc4-1989-4a37-9ab0-0bdea654bb5d" to a digest: GET https://ghcr.io/v2/making/workloads/hello-nodejs-demo-bundle/manifests/9839ebc4-1989-4a37-9ab0-0bdea654bb5d: MANIFEST_UNKNOWN: manifest unknown
🛶 Pods
NAME READY STATUS RESTARTS AGE
hello-nodejs-build-1-build-pod 0/1 Init:1/6 0 14s
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 3m40s gitrepositories.source.toolkit.fluxcd.io/hello-nodejs
image-provider True True 2m16s images.kpack.io/hello-nodejs
config-provider True True 2m3s podintents.conventions.carto.run/hello-nodejs
app-config True True 2m3s configmaps/hello-nodejs
service-bindings True True 2m3s configmaps/hello-nodejs-with-claims
api-descriptors True True 2m3s configmaps/hello-nodejs-with-api-descriptors
config-writer True True 68s runnables.carto.run/hello-nodejs-config-writer
🚚 Delivery
name: delivery-basic
NAME READY HEALTHY UPDATED RESOURCE
source-provider True True 34s imagerepositories.source.apps.tanzu.vmware.com/hello-nodejs-delivery
deployer True True 32s apps.kappctrl.k14s.io/hello-nodejs
💬 Messages
No messages found.
🛶 Pods
NAME READY STATUS RESTARTS AGE
hello-nodejs-00001-deployment-7586f87fd8-qsf2q 2/2 Running 0 35s
hello-nodejs-build-1-build-pod 0/1 Completed 0 3m40s
hello-nodejs-config-writer-m8tf6-pod 0/1 Completed 0 2m2s
🚢 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"

"THIS IS UNSAFE"を入力

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.4/tap/spring-boot-conventions-configuring-spring-boot-actuators.html
確認が終わればWorkloadを削除します。
tanzu apps workload delete -n demo spring-music -y
GitOpsでデプロイする
まず、manifestを管理するgitレポジトリをGitHubで作成ます。READMEのみを含む https://github.com/making/hello-nodejs-manifests を作成しました。

GitレポジトリにpushするためのSecretを作成します。HTTP(S) Basic-authかSSHが選べます。 ここではBasic-authを使用します。
https://github.com/settings/tokens からrepoへのアクセス権があるPersonal access tokensを生成してください。

この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を設定 (TAP 1.4から)
Namespace Provisionerによるカスタマイズ方法は次のドキュメントに記載されています。
https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.4/tap/namespace-provisioner-how-tos.html
追加したいリソースのテンプレートをtap-values.yaml
のnamespace_provisioner.additional_sources
に記述できます。このドキュメントは"GitOps"と言ってGitからマニフェストを取得する方法を紹介していますが、
実際はkapp controllerのApp CRでマニフェストをfetchしてるので、App CR specのfetch
で取得できるものであれば、Gitでなくてもマニフェストを配置できます。
今回はgit
ではなくinline
を使って、tap-values.yaml
に追加したいリソースを直接記述します。
次のようにtap-values.yaml
にnamespace_provisioner
の設定を追記します。
GITHUB_USERNAME=making
GITHUB_API_TOKEN=ghp_******
cat <<EOF >> tap-values.yaml
namespace_provisioner:
additional_sources:
- inline:
paths:
git-basic.yaml: |
---
apiVersion: v1
kind: Secret
metadata:
name: git-basic
annotations:
tekton.dev/git-0: https://github.com
type: kubernetes.io/basic-auth
stringData:
username: "${GITHUB_USERNAME}"
password: "${GITHUB_API_TOKEN}"
path: _ytt_lib/git-basic
- inline:
paths:
add-git-basic.lib.yaml: |
#@ load("@ytt:overlay", "overlay")
#@ def customize():
#@overlay/match by=overlay.subset({"kind": "ServiceAccount", "metadata": {"name": "default"}}), expects="0+"
---
secrets:
- name: git-basic
#@ end
path: _ytt_lib/customize
EOF
path
は必ず_ytt_lib/
から始める必要があります。
また、デフォルトで作られるリソース(default
ServiceAccount)などをytt overlayでカスタマイズしたい場合は、path
は_ytt_lib/customize
で固定で、ファイル名は.lib.yaml
で終える必要があり、overlayを記述した関数customize
を定義する必要がああります。
使用条件は https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.4/tap/namespace-provisioner-how-tos.html#customizing-the-default-resources-that-get-provisioned-4 に記載されています。
次のコマンドでTAPをアップデートすれば、apps.tanzu.vmware.com/tap-ns
ラベルのついた全てのNamespaceにgit-basic
というSecretが作成され、default
Service Accountのsecrets
にgit-basic
が追加されます。
tanzu package installed update -n tap-install tap -f tap-values.yaml
kapp
CLIでリソースを確認すると
$ kapp inspect -n tap-namespace-provisioning -a provisioner.app
Target cluster 'https://127.0.0.1:57671' (nodes: kind-control-plane)
Resources in app 'provisioner.app'
Namespace Name Kind Owner Rs Ri Age
demo default ServiceAccount kapp ok - 1h
^ default-permit-deliverable RoleBinding kapp ok - 1h
^ default-permit-workload RoleBinding kapp ok - 1h
^ git-basic Secret kapp ok - 1h
^ registries-credentials Secret kapp ok - 1h
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レポジトリを見ると次のコミットが自動で行われていることがわかります。

URLにアクセスします。
$ curl -k https://hello-demo.127-0-0-1.sslip.io
Hello World!
ソースコードを変更してgit pushすると、新しいコンテナイメージがビルドされ、manifestも新しいイメージのdigestを使用するようにcommit & pushされます。 次のようなコミットになります。

GitOpsでpull requestを使用する
TAP 1.2からはmanifestの変更を直接commit & pushする代わり、pull requestを送ることができるようになりました。
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が作成されます。


このPull Requestをマージすると、変更結果がデプロイされます。
確認が終わればWorkloadを削除します。
tanzu apps workload delete -n demo hello -y
Kaniko経由でDockerfileを使う
TAP 1.2からはコンテナイメージを作成する際にCloud Native Buildpacksではなく、Dockerfileを使用できます。
内部的にはkpackではなく、kanikoが使用されます。
tanzu apps workload apply hello-nodejs \
--app hello-nodejs \
--git-repo https://github.com/making/hello-nodejs \
--git-branch master \
--param dockerfile=./Dockerfile \
--type web \
-n demo \
-y
stern -n demo hello-nodejs
確認が終わればWorkloadを削除します。
tanzu apps workload delete -n demo hello-nodejs -y
TAPを使うとCI/CDのフローをtanzu apps workload
だけで作成できるのが便利ですね。