IK.AM

@making's tech note


Tanzu Application Platform 1.1 (Iterate Profile) をKindにインストールし"Source Test to URL"を試すメモ

🗃 {Dev/CaaS/Kubernetes/TAP}
🏷 Kubernetes 🏷 Cartographer 🏷 kind 🏷 Tanzu 🏷 TAP 🏷 Knative 🏷 Tekton 
🗓 Updated at 2022-06-30T17:51:48+09:00  🗓 Created at 2022-06-30T01:31:21+09:00 {✒️️ Edit  ⏰ History  🗑 Delete}

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

本記事ではTAPをInstallし、Out of the Box Supply Chain with Testingを有効にし、"Hello World"なアプリケーションをソースコードからテストを経てデプロイする機能("Source Test to URL")を試します。 また、HTTPSを有効にします。

目次

Kindクラスタの作成

cat <<EOF > kind-expose-port.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
 - role: control-plane
   extraPortMappings:
   - containerPort: 31443 # expose port 31443 of the node to port 80 on the host for use later by Contour ingress (envoy)
     hostPort: 443
   - containerPort: 31080 # expose port 31080 of the node to port 80 on the host for use later by Contour ingress (envoy)
     hostPort: 80
EOF
kind create cluster --config kind-expose-port.yaml --image kindest/node:v1.23.6

TAP 1.1はK8s 1.24では動かないので、kindのクラスタバージョンでk8sのバージョンを明示します。

Linux上でkindを使用する場合は、“too many open files”が発生する可能性があるので、 次のコマンドを実行してください。

sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl fs.inotify.max_user_instances=512

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.1.0' --product-file-id=1191985
# Linux
pivnet download-product-files --product-slug='tanzu-cluster-essentials' --release-version='1.1.0' --product-file-id=1191987
# Windows
pivnet download-product-files --product-slug='tanzu-cluster-essentials' --release-version='1.1.0' --product-file-id=1191983
TANZUNET_USERNAME=...
TANZUNET_PASSWORD=...

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

export INSTALL_BUNDLE=registry.tanzu.vmware.com/tanzu-cluster-essentials/cluster-essentials-bundle:1.1.0
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 ..

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.1.1 \
  --namespace tap-install

Iterate Profileのインストール

GITHUB_USERNAME=...
GITHUB_API_TOKEN=...

cat <<EOF > tap-values.yml
profile: iterate

ceip_policy_disclosed: true

cnrs:
  domain_name: vcap.me
  domain_template: "{{.Name}}-{{.Namespace}}.{{.Domain}}"
  default_tls_secret: tanzu-system-ingress/cnrs-default-tls
  provider: local

buildservice:
  kp_default_repository: ghcr.io/${GITHUB_USERNAME}/build-service
  kp_default_repository_username: ${GITHUB_USERNAME}
  kp_default_repository_password: ${GITHUB_API_TOKEN}
  tanzunet_username: ${TANZUNET_USERNAME}
  tanzunet_password: ${TANZUNET_PASSWORD}
  enable_automatic_dependency_updates: true
  descriptor_name: full

supply_chain: testing

ootb_supply_chain_testing:
  registry:
    server: ghcr.io
    repository: ${GITHUB_USERNAME}

contour:
  envoy:
    service:
      nodePorts:
        http: 31080
        https: 31443

package_overlays:
- name: cnrs
  secrets:
  - name: cnrs-default-tls
  - name: cnrs-slim
EOF

*.vcap.me127.0.0.1に解決されます。

Cloud Native Runtimes (Knative) で使用するデフォルトのTLS証明書を用意するための次の定義をoverlayで作成します。以下のドキュメントを参考にしました。

cat <<EOF > cnrs-default-tls.yml
#@ load("@ytt:data", "data")
#@ load("@ytt:overlay", "overlay")
#@ namespace = data.values.ingress.external.namespace
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: cnrs-selfsigned-issuer
  namespace: #@ namespace
spec:
  selfSigned: { }
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: cnrs-ca
  namespace: #@ namespace
spec:
  commonName: cnrs-ca
  isCA: true
  issuerRef:
    kind: Issuer
    name: cnrs-selfsigned-issuer
  secretName: cnrs-ca
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: cnrs-ca-issuer
  namespace: #@ namespace
spec:
  ca:
    secretName: cnrs-ca
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: cnrs-default-tls
  namespace: #@ namespace
spec:
  dnsNames:
  - #@ "*.{}".format(data.values.domain_name)
  issuerRef:
    kind: Issuer
    name: cnrs-ca-issuer
  secretName: cnrs-default-tls
---
apiVersion: projectcontour.io/v1
kind: TLSCertificateDelegation
metadata:
  name: contour-delegation
  namespace: #@ namespace
spec:
  delegations:
  - secretName: cnrs-default-tls
    targetNamespaces:
    - "*"
#@overlay/match by=overlay.subset({"metadata":{"name":"config-network"}, "kind": "ConfigMap"})
---
data:
  #@overlay/match missing_ok=True
  default-external-scheme: https
EOF

Cloud Native RuntimesからKnative Serving以外のリソースを削除するoverlayを作成します。

cat <<EOF > cnrs-slim.yml
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"metadata":{"namespace":"knative-eventing"}}), expects="1+"
#@overlay/remove
---
#@overlay/match by=overlay.subset({"metadata":{"namespace":"knative-sources"}}), expects="1+"
#@overlay/remove
---
#@overlay/match by=overlay.subset({"metadata":{"namespace":"triggermesh"}}), expects="1+"
#@overlay/remove
---
#@overlay/match by=overlay.subset({"metadata":{"namespace":"vmware-sources"}}), expects="1+"
#@overlay/remove
---
EOF

overlayファイルをSecretとして作成します。

kubectl -n tap-install create secret generic cnrs-default-tls \
  -o yaml \
  --dry-run=client \
  --from-file=cnrs-default-tls.yml \
  | kubectl apply -f-

kubectl -n tap-install create secret generic cnrs-slim \
  -o yaml \
  --dry-run=client \
  --from-file=cnrs-slim.yml \
  | kubectl apply -f-

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

tanzu package install tap -p tap.tanzu.vmware.com -v 1.1.1 --values-file tap-values.yml -n tap-install

インストールの進捗は次のコマンドで確認します。

watch kubectl get app -n tap-install

全てのappが Reconcile succeeded になるまで待ちます。

$ kubectl get app -n tap-install 
NAME                       DESCRIPTION           SINCE-DEPLOY   AGE
appliveview                 Reconcile succeeded   9m53s          143m
appliveview-connector       Reconcile succeeded   3m25s          153m
appliveview-conventions     Reconcile succeeded   14m            149m
buildservice                Reconcile succeeded   97s            153m
cartographer                Reconcile succeeded   8m8s           152m
cert-manager                Reconcile succeeded   10m            153m
cnrs                        Reconcile succeeded   5m39s          143m
contour                     Reconcile succeeded   84s            152m
conventions-controller      Reconcile succeeded   7m7s           152m
developer-conventions       Reconcile succeeded   4m20s          149m
fluxcd-source-controller    Reconcile succeeded   4m41s          153m
image-policy-webhook        Reconcile succeeded   2m55s          152m
ootb-delivery-basic         Reconcile succeeded   7m36s          150m
ootb-supply-chain-testing   Reconcile succeeded   17m            150m
ootb-templates              Reconcile succeeded   8m25s          150m
service-bindings            Reconcile succeeded   3m10s          153m
services-toolkit            Reconcile succeeded   3m55s          153m
source-controller           Reconcile succeeded   4m50s          153m
spring-boot-conventions     Reconcile succeeded   4m16s          149m
tap                         Reconcile succeeded   7m14s          153m
tap-auth                    Reconcile succeeded   6m55s          153m
tap-telemetry               Reconcile succeeded   5m49s          153m
tekton-pipelines            Reconcile succeeded   5m1s           153m

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

$ kubectl get packageinstall -n tap-install 
NAME                       PACKAGE NAME                                         PACKAGE VERSION   DESCRIPTION           AGE
appliveview                 backend.appliveview.tanzu.vmware.com                 1.1.1             Reconcile succeeded   144m
appliveview-connector       connector.appliveview.tanzu.vmware.com               1.1.1             Reconcile succeeded   153m
appliveview-conventions     conventions.appliveview.tanzu.vmware.com             1.1.1             Reconcile succeeded   149m
buildservice                buildservice.tanzu.vmware.com                        1.5.1             Reconcile succeeded   153m
cartographer                cartographer.tanzu.vmware.com                        0.3.0             Reconcile succeeded   153m
cert-manager                cert-manager.tanzu.vmware.com                        1.5.3+tap.2       Reconcile succeeded   153m
cnrs                        cnrs.tanzu.vmware.com                                1.2.0             Reconcile succeeded   144m
contour                     contour.tanzu.vmware.com                             1.18.2+tap.2      Reconcile succeeded   153m
conventions-controller      controller.conventions.apps.tanzu.vmware.com         0.6.3             Reconcile succeeded   153m
developer-conventions       developer-conventions.tanzu.vmware.com               0.6.0             Reconcile succeeded   149m
fluxcd-source-controller    fluxcd.source.controller.tanzu.vmware.com            0.16.4            Reconcile succeeded   153m
image-policy-webhook        image-policy-webhook.signing.apps.tanzu.vmware.com   1.1.2             Reconcile succeeded   153m
ootb-delivery-basic         ootb-delivery-basic.tanzu.vmware.com                 0.7.1             Reconcile succeeded   150m
ootb-supply-chain-testing   ootb-supply-chain-testing.tanzu.vmware.com           0.7.1             Reconcile succeeded   150m
ootb-templates              ootb-templates.tanzu.vmware.com                      0.7.1             Reconcile succeeded   150m
service-bindings            service-bindings.labs.vmware.com                     0.7.1             Reconcile succeeded   153m
services-toolkit            services-toolkit.tanzu.vmware.com                    0.6.0             Reconcile succeeded   153m
source-controller           controller.source.apps.tanzu.vmware.com              0.3.3             Reconcile succeeded   153m
spring-boot-conventions     spring-boot-conventions.tanzu.vmware.com             0.4.0             Reconcile succeeded   149m
tap                         tap.tanzu.vmware.com                                 1.1.1             Reconcile succeeded   153m
tap-auth                    tap-auth.tanzu.vmware.com                            1.0.1             Reconcile succeeded   153m
tap-telemetry               tap-telemetry.tanzu.vmware.com                       0.1.4             Reconcile succeeded   153m
tekton-pipelines            tekton.tanzu.vmware.com                              0.33.5            Reconcile succeeded   153m

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

$ kubectl get pod -A
NAMESPACE                   NAME                                                  READY   STATUS    RESTARTS   AGE
app-live-view-connector     application-live-view-connector-tb8dj                 1/1     Running   0          152m
app-live-view-conventions   appliveview-webhook-584458f5b5-czfsv                  1/1     Running   0          148m
app-live-view               application-live-view-server-f9fbd458c-g7t77          1/1     Running   0          142m
build-service               build-pod-image-fetcher-rtmrb                         5/5     Running   0          152m
build-service               dependency-updater-controller-5d875b4d6d-6djzk        1/1     Running   0          76m
build-service               secret-syncer-controller-59c88497c6-7z4nc             1/1     Running   0          152m
build-service               smart-warmer-image-fetcher-8qwn9                      4/4     Running   0          50m
build-service               warmer-controller-5df5fc6897-ndkq8                    1/1     Running   0          152m
cartographer-system         cartographer-controller-77886667b5-g8scn              1/1     Running   0          152m
cert-injection-webhook      cert-injection-webhook-66584fb9f4-kts4f               1/1     Running   0          152m
cert-manager                cert-manager-7d46b7749-brpsm                          1/1     Running   0          152m
cert-manager                cert-manager-cainjector-7c79f5b947-58g4v              1/1     Running   0          152m
cert-manager                cert-manager-webhook-6656cb99dd-tpfqp                 1/1     Running   0          152m
conventions-system          conventions-controller-manager-78d9f869d-dt668        1/1     Running   0          151m
developer-conventions       webhook-77675dbc8d-bwdsd                              1/1     Running   0          148m
flux-system                 source-controller-7f6589c9c9-kkwcw                    1/1     Running   0          152m
image-policy-system         image-policy-controller-manager-7dd95b8798-87j95      2/2     Running   0          151m
kapp-controller             kapp-controller-d97d54f99-922rv                       1/1     Running   0          166m
knative-serving             activator-5bbb6d9549-tmwtq                            1/1     Running   0          142m
knative-serving             autoscaler-5f495f859f-4mhjl                           1/1     Running   0          142m
knative-serving             autoscaler-hpa-bf4bbccdb-z5n2p                        1/1     Running   0          142m
knative-serving             controller-656946dbbc-bw695                           1/1     Running   0          142m
knative-serving             domain-mapping-66976c7d8d-k2mjm                       1/1     Running   0          142m
knative-serving             domainmapping-webhook-7457844756-h2jjz                1/1     Running   0          142m
knative-serving             net-certmanager-controller-7ff9d5f45-2wm2r            1/1     Running   0          142m
knative-serving             net-certmanager-webhook-85bbb4bff7-qmqfn              1/1     Running   0          142m
knative-serving             net-contour-controller-844476c6fd-w6vw9               1/1     Running   0          142m
knative-serving             webhook-54c9776797-wcgx6                              1/1     Running   0          142m
kpack                       kpack-controller-6d6496c976-bmss6                     1/1     Running   0          152m
kpack                       kpack-webhook-697f99c8df-kf6q5                        1/1     Running   0          152m
kube-system                 coredns-64897985d-jkp8g                               1/1     Running   0          3h7m
kube-system                 coredns-64897985d-pgqct                               1/1     Running   0          3h7m
kube-system                 etcd-kind-control-plane                               1/1     Running   0          3h7m
kube-system                 kindnet-mq2hs                                         1/1     Running   0          3h7m
kube-system                 kube-apiserver-kind-control-plane                     1/1     Running   0          3h7m
kube-system                 kube-controller-manager-kind-control-plane            1/1     Running   0          3h7m
kube-system                 kube-proxy-t8jqn                                      1/1     Running   0          3h7m
kube-system                 kube-scheduler-kind-control-plane                     1/1     Running   0          3h7m
local-path-storage          local-path-provisioner-66b445c94-djcwd                1/1     Running   0          3h7m
secretgen-controller        secretgen-controller-5d949bf475-gsz45                 1/1     Running   0          164m
service-bindings            manager-79db8c7bb8-rnwvp                              1/1     Running   0          152m
services-toolkit            services-toolkit-controller-manager-ccd8bcd9b-54hwg   1/1     Running   0          152m
source-system               source-controller-manager-764984f9bc-6zc9w            1/1     Running   0          152m
spring-boot-convention      spring-boot-webhook-54855c95bd-6cvxs                  1/1     Running   0          148m
stacks-operator-system      controller-manager-846b6b86d4-6stsg                   1/1     Running   0          152m
tanzu-system-ingress        contour-5476f95c45-cpxr4                              1/1     Running   0          151m
tanzu-system-ingress        contour-5476f95c45-z9szd                              1/1     Running   0          151m
tanzu-system-ingress        envoy-nddkw                                           2/2     Running   0          151m
tap-telemetry               tap-telemetry-controller-7b8c6c795c-wsb4k             1/1     Running   0          152m
tekton-pipelines            tekton-pipelines-controller-69cfb64974-jnh8z          1/1     Running   0          152m
tekton-pipelines            tekton-pipelines-webhook-5c7f96999c-v9llk             1/1     Running   0          152m

Workloadのデプロイ

Workloadを作成するための事前準備

RBACの設定

https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.1/tap/GUID-scc-ootb-supply-chain-basic.html (一部変更しています)

kubectl create ns demo
tanzu secret registry add registry-credentials --server ghcr.io --username ${GITHUB_USERNAME} --password ${GITHUB_API_TOKEN} --namespace demo
cat <<EOF | kubectl -n demo apply -f -
apiVersion: v1
kind: Secret
metadata:
  name: tap-registry
  annotations:
    secretgen.carvel.dev/image-pull-secret: ""
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: e30K
---
apiVersion: v1
kind: Secret
metadata:
  name: git-ssh
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: default
secrets:
  - name: registry-credentials
  - name: git-ssh
imagePullSecrets:
  - name: registry-credentials
  - name: tap-registry
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: default-permit-deliverable
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: deliverable
subjects:
  - kind: ServiceAccount
    name: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: default-permit-workload
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: workload
subjects:
  - kind: ServiceAccount
    name: default
EOF
Tekton Pipelineの作成

https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/1.1/tap/GUID-scc-ootb-supply-chain-testing.html

Mavenのテストを作成します。

cat <<'EOF' > pipeline-maven.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: maven-test-pipeline
  labels:
    apps.tanzu.vmware.com/pipeline: test
spec:
  params:
  - name: source-url
  - name: source-revision
  tasks:
  - name: test
    params:
    - name: source-url
      value: $(params.source-url)
    - name: source-revision
      value: $(params.source-revision)
    taskSpec:
      params:
      - name: source-url
      - name: source-revision
      steps:
      - name: test
        image: eclipse-temurin:17
        script: |-
          set -ex
          cd `mktemp -d`
          curl -s $(params.source-url) | tar -xzvf -
          ./mvnw clean test -V --no-transfer-progress
EOF

kubectl apply -f pipeline-maven.yaml -n demo

Javaアプリのデプロイ

tanzu apps workload apply hello-servlet \
  --app hello-servlet \
  --git-repo https://github.com/making/hello-servlet \
  --git-branch master \
  --type web \
  --label apps.tanzu.vmware.com/has-tests=true \
  -n demo \
  -y
tanzu apps workload tail hello-servlet -n demo

作成されるリソースを確認したければ次のコマンドをwatchしてください。

watch kubectl get workload,pod,gitrepo,pipelinerun,imgs,build,podintent,taskrun,imagerepository,app,ksvc,certificate,httpproxy -n demo -owide
NAME                               SOURCE                                    SUPPLYCHAIN          READY   REASON   AGE
workload.carto.run/hello-servlet   https://github.com/making/hello-servlet   source-test-to-url   True    Ready    6m40s

NAME                                                  READY   STATUS        RESTARTS   AGE     IP            NODE                 NOMINATED NODE   READINESS GATES
pod/hello-servlet-00001-deployment-7fd4d86dc6-hx8xv   2/2     Terminating   0          86s     10.244.0.73   kind-control-plane   <none>           <none>
pod/hello-servlet-build-1-build-pod                   0/1     Completed     0          4m31s   10.244.0.71   kind-control-plane   <none>           <none>
pod/hello-servlet-config-writer-8frnv-pod             0/1     Completed     0          2m20s   10.244.0.72   kind-control-plane   <none>           <none>
pod/hello-servlet-zccxz-test-pod                      0/1     Completed     0          6m30s   10.244.0.69   kind-control-plane   <none>           <none>

NAME                                                   URL                                       READY   STATUS                                                              AGE
gitrepository.source.toolkit.fluxcd.io/hello-servlet   https://github.com/making/hello-servlet   True    Fetched revision: master/52d3ce0ebf10deab0495845fd36027c5da39efc9   6m38s

NAME                                         SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
pipelinerun.tekton.dev/hello-servlet-zccxz   True        Succeeded   6m30s       4m42s

NAME                           LATESTIMAGE                                                                                                 READY
image.kpack.io/hello-servlet   ghcr.io/making/hello-servlet-demo@sha256:7e6935110173f8b78a96428c1aaf61c89f737394fc73c81a179757b78b8b6d10   True

NAME                                   IMAGE                                                                                                       SUCCEEDED
build.kpack.io/hello-servlet-build-1   ghcr.io/making/hello-servlet-demo@sha256:7e6935110173f8b78a96428c1aaf61c89f737394fc73c81a179757b78b8b6d10   True

NAME                                                        READY   REASON               AGE
podintent.conventions.apps.tanzu.vmware.com/hello-servlet   True    ConventionsApplied   2m34s

NAME                                                   SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
taskrun.tekton.dev/hello-servlet-config-writer-8frnv   True        Succeeded   2m20s       109s
taskrun.tekton.dev/hello-servlet-zccxz-test            True        Succeeded   6m30s       4m42s

NAME                                                                  IMAGE                                                                           URL                                                                                                                                                                                                      READY   REASON   AGE
imagerepository.source.apps.tanzu.vmware.com/hello-servlet-delivery   ghcr.io/making/hello-servlet-demo-bundle:2f8b6353-40dc-44c3-b8cd-e9bd76a79bf9   http://source-controller-manager-artifact-service.source-system.svc.cluster.local./imagerepository/demo/hello-servlet-delivery/c7b03e516e1ee38832d8a3155218e57ab73d39565784a48ac118f1f0929e0d78.tar.gz   True    Ready    6m35s

NAME                                 DESCRIPTION           SINCE-DEPLOY   AGE
app.kappctrl.k14s.io/hello-servlet   Reconcile succeeded   89s            6m35s

NAME                                        URL                                  LATESTCREATED         LATESTREADY           READY   REASON
service.serving.knative.dev/hello-servlet   https://hello-servlet-demo.vcap.me   hello-servlet-00001   hello-servlet-00001   True    

NAME                                                                                     FQDN                                   TLS SECRET                              STATUS   STATUS DESCRIPTION
httpproxy.projectcontour.io/hello-servlet-contour-hello-servlet-demo.vcap.me             hello-servlet-demo.vcap.me             tanzu-system-ingress/cnrs-default-tls   valid    Valid HTTPProxy
httpproxy.projectcontour.io/hello-servlet-contour-hello-servlet.demo                     hello-servlet.demo                     tanzu-system-ingress/cnrs-default-tls   valid    Valid HTTPProxy
httpproxy.projectcontour.io/hello-servlet-contour-hello-servlet.demo.svc                 hello-servlet.demo.svc                 tanzu-system-ingress/cnrs-default-tls   valid    Valid HTTPProxy
httpproxy.projectcontour.io/hello-servlet-contour-hello-servlet.demo.svc.cluster.local   hello-servlet.demo.svc.cluster.local   tanzu-system-ingress/cnrs-default-tls   valid    Valid HTTPProxy
$ tanzu apps workload get -n demo hello
# hello-servlet: Ready
---
lastTransitionTime: "2022-06-29T16:27:49Z"
message: ""
reason: Ready
status: "True"
type: Ready

Pods
NAME                                              STATUS        RESTARTS   AGE
hello-servlet-00001-deployment-7fd4d86dc6-hx8xv   Terminating   0          109s
hello-servlet-build-1-build-pod                   Succeeded     0          4m54s
hello-servlet-config-writer-8frnv-pod             Succeeded     0          2m43s
hello-servlet-zccxz-test-pod                      Succeeded     0          6m53s

Knative Services
NAME            READY   URL
hello-servlet   Ready   https://hello-servlet-demo.vcap.me
$ kubectl logs -n demo -l app.kubernetes.io/component=test,app.kubernetes.io/part-of=hello-servlet --tail=-1
+ mktemp -d
+ cd /tmp/tmp.scJHLY6S4l
+ curl -s http://source-controller.flux-system.svc.cluster.local./gitrepository/demo/hello-servlet/52d3ce0ebf10deab0495845fd36027c5da39efc9.tar.gz
+ tar -xzvf -
.git/HEAD
.git/config
.git/index
.git/objects/pack/pack-478b43ebe16a8a7de9bbe21585cb2d53165b1d4f.idx
.git/objects/pack/pack-478b43ebe16a8a7de9bbe21585cb2d53165b1d4f.pack
.git/refs/heads/master
.git/refs/remotes/origin/master
.git/shallow
.mvn/wrapper/maven-wrapper.jar
.mvn/wrapper/maven-wrapper.properties
README.md
manifest.yml
mvnw
mvnw.cmd
pom.xml
src/main/java/com/example/hello/HelloServlet.java
src/test/java/com/example/hello/HelloServletTest.java
+ ./mvnw clean test -V --no-transfer-progress
Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /root/.m2/wrapper/dists/apache-maven-3.6.2-bin/664rr97se3slubllb7r6fll7u/apache-maven-3.6.2-bin.zip to /root/.m2/wrapper/dists/apache-maven-3.6.2-bin/664rr97se3slubllb7r6fll7u
Set executable permissions for: /root/.m2/wrapper/dists/apache-maven-3.6.2-bin/664rr97se3slubllb7r6fll7u/apache-maven-3.6.2/bin/mvn
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T15:06:16Z)
Maven home: /root/.m2/wrapper/dists/apache-maven-3.6.2-bin/664rr97se3slubllb7r6fll7u/apache-maven-3.6.2
Java version: 17.0.3, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.10.104-linuxkit", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< com.example.hello:hello-servlet >-------------------
[INFO] Building hello-servlet 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello-servlet ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-servlet ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/tmp.scJHLY6S4l/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello-servlet ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /tmp/tmp.scJHLY6S4l/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello-servlet ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/tmp.scJHLY6S4l/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hello-servlet ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /tmp/tmp.scJHLY6S4l/target/test-classes
[WARNING] /tmp/tmp.scJHLY6S4l/src/test/java/com/example/hello/HelloServletTest.java: /tmp/tmp.scJHLY6S4l/src/test/java/com/example/hello/HelloServletTest.java uses or overrides a deprecated API.
[WARNING] /tmp/tmp.scJHLY6S4l/src/test/java/com/example/hello/HelloServletTest.java: Recompile with -Xlint:deprecation for details.
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello-servlet ---
[INFO] Surefire report directory: /tmp/tmp.scJHLY6S4l/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.hello.HelloServletTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.082 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  50.474 s
[INFO] Finished at: 2022-06-29T16:25:28Z
[INFO] ------------------------------------------------------------------------
$ curl -k https://hello-servlet-demo.vcap.me
Hello World!

TektonのPipelineでキャッシュを使う

こちらの記事

1つのnamespaceに複数のTekton Pipelineを使えるようにする

こちらの記事

Workloadの削除

tanzu apps workload delete hello-servlet -n demo -y
kubectl delete -f pipeline-maven.yaml -n demo