IK.AM

@making's tech note


Tanzu Application PlatformにRustのWebアプリをデプロイする

🗃 {Dev/CaaS/Kubernetes/TAP}
🏷 Cartographer 🏷 Kubernetes 🏷 Rust 🏷 TAP 🏷 Tanzu 🏷 Tanzu Build Service 
🗓 Updated at 2022-09-14T17:44:56+09:00  🗓 Created at 2022-09-14T17:39:37+09:00 {✒️️ Edit  ⏰ History  🗑 Delete}

こちらの記事でrust buildpackを使ってRustアプリのコンテナイメージを作成しました。

今回はTanzu Application Platform (TAP)上でrust buildpackを使ってアプリをデプロイできるようににします。

TAPでRustを使えるようにするには、ClusterStoreにRust Buildpackを追加し、ClusterBuilderにRustのgroupを追加する必要があります。
TAP 1.2以降では、使用するStore, Stack, BuilderはTanzuNetDependencyUpdaterリソースに定義されているので、 これを更新するのが楽です。TAP 1.1以下では本記事の内容は使えません。

TanzuNetDependencyUpdaterはlite dependencies (デフォルト)を使う場合と、full dependeniesを使う場合で異なります。

lite dependenciesを使用している場合

こちらの記事でインストールした環境にRust Buildpackを追加します。

次のようにTanzuNetDependencyUpdaterにClusterStoreとClusterBuilderを追加するoverlayを用意します。

rust buildpackのReleases を見て、執筆時点で最新の0.18.0を使用します。

cat <<EOF > buildservice-add-rust-buildpack.yaml
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"metadata":{"name":"dependency-updater"}, "kind": "TanzuNetDependencyUpdater"})
---
spec:
  inlineDescriptor:
    clusterStores:
    #@overlay/match by="name", missing_ok=True
    - name: default
      sources:
      #@overlay/append
      - image: docker.io/paketocommunity/rust:0.18.0
    clusterBuilders:
    #@overlay/match by="name", missing_ok=True
    - name: base
      order:
      #@overlay/append
      - group:
        - id: paketo-community/rust
    #@overlay/match by="name", missing_ok=True
    - name: full
      order:
      #@overlay/append
      - group:
        - id: paketo-community/rust
    #@overlay/match by="name", missing_ok=True
    - name: tiny
      order:
      #@overlay/append
      - group:
        - id: paketo-community/rust            
EOF

次のコマンドでoverlayファイルのSecretを作成します。

kubectl -n tap-install create secret generic buildservice-add-rust-buildpack \
  -o yaml \
  --dry-run=client \
  --from-file=buildservice-add-rust-buildpack.yaml \
  | kubectl apply -f-

tap-values.ymlpackage_overlaysに次の項目を追加します。

package_overlays:
# ...
- name: buildservice
  secrets:
  - name: buildservice-add-rust-buildpack 

次のコマンドでTAPを更新します。

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

Builderの更新の進捗は次のログを見ることで確認できます。

$ kubectl logs -n build-service deploy/dependency-updater-controller -f

Importing ... の後 Reconcile succeededが出ていればアップロード完了です。

{"level":"info","ts":1663132459.9617548,"caller":"dependencyupdater/logger.go:21","msg":"Importing ClusterStore 'default'..."}
{"level":"info","ts":1663132463.9133067,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132468.315304,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132472.4485848,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132476.4138098,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132480.417098,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132484.858053,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132488.84969,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132491.4091198,"caller":"dependencyupdater/logger.go:16","msg":"\tBuildpackage already exists in the store"}
{"level":"info","ts":1663132491.409171,"caller":"dependencyupdater/logger.go:21","msg":"Importing ClusterStack 'base'..."}
{"level":"info","ts":1663132498.387017,"caller":"dependencyupdater/logger.go:21","msg":"Uploading to 'tap11046.azurecr.io/build-service'..."}
{"level":"info","ts":1663132506.5005634,"caller":"dependencyupdater/logger.go:21","msg":"Importing ClusterStack 'default'..."}
{"level":"info","ts":1663132513.2477891,"caller":"dependencyupdater/logger.go:21","msg":"Uploading to 'tap11046.azurecr.io/build-service'..."}
{"level":"info","ts":1663132521.6199417,"caller":"dependencyupdater/logger.go:21","msg":"Importing ClusterBuilder 'base'..."}
{"level":"info","ts":1663132521.620088,"caller":"dependencyupdater/logger.go:21","msg":"Importing ClusterBuilder 'default'..."}
{"level":"error","ts":1663132522.1857035,"caller":"controller/controller.go:564","msg":"Reconcile error","knative.dev/kind":"tanzunetdependencyupdaters.buildservice.tanzu.vmware.com","duration":62.287972661,"error":"Operation cannot be fulfilled on tanzunetdependencyupdaters.buildservice.tanzu.vmware.com \"dependency-updater\": the object has been modified; please apply your changes to the latest version and try again","stacktrace":"knative.dev/pkg/controller.(*Impl).handleErr\n\tknative.dev/pkg@v0.0.0-20210902173607-844a6bc45596/controller/controller.go:564\nknative.dev/pkg/controller.(*Impl).processNextWorkItem\n\tknative.dev/pkg@v0.0.0-20210902173607-844a6bc45596/controller/controller.go:541\nknative.dev/pkg/controller.(*Impl).RunContext.func3\n\tknative.dev/pkg@v0.0.0-20210902173607-844a6bc45596/controller/controller.go:477"}
{"level":"info","ts":1663132522.186615,"caller":"controller/controller.go:548","msg":"Reconcile succeeded","knative.dev/kind":"tanzunetdependencyupdaters.buildservice.tanzu.vmware.com","knative.dev/traceid":"12a2a247-bb21-4ce9-bd2f-5ffcc18ad8f2","knative.dev/key":"build-service/dependency-updater","duration":0.00081851}

ClusterStoreやClusterBuilderの状態はkp CLIを使うと確認しやすいです。

次のコマンドでClusterStoreを確認して、paketo-community/rustが含まれていればOKです。

$ kp clusterstore status default                     
Status:    Ready

BUILDPACKAGE ID                            VERSION    HOMEPAGE
paketo-community/rust                      0.18.0     https://github.com/paketo-community/rust
tanzu-buildpacks/dotnet-core-lite          1.14.3     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-dotnet-core-dotnet-core-buildpack.html
tanzu-buildpacks/go-lite                   1.12.0     https://docs.pivotal.io/tanzu-buildpacks/go/go-buildpack.html
tanzu-buildpacks/java-lite                 6.27.0     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-java-java-buildpack.html
tanzu-buildpacks/java-native-image-lite    6.18.1     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-java-native-image-java-native-image-buildpack.html
tanzu-buildpacks/nginx-lite                0.6.0      https://docs.pivotal.io/tanzu-buildpacks/nginx/nginx-buildpack.html
tanzu-buildpacks/nodejs-lite               1.14.2     https://docs.pivotal.io/tanzu-buildpacks/nodejs/nodejs-buildpack.html
tanzu-buildpacks/python-lite               2.0.0 

次のコマンドでClusterBuilderを確認して、paketo-community/rust@0.18.0 が含まれていればOKです。

$ kp clusterbuilder status base
...

DETECTION ORDER                                     
Group #1                                            
  tanzu-buildpacks/dotnet-core-lite@1.14.3          
Group #2                                            
  tanzu-buildpacks/nodejs-lite@1.14.2               
Group #3                                            
  tanzu-buildpacks/go-lite@1.12.0                   
Group #4                                            
  tanzu-buildpacks/python-lite@2.0.0                
Group #5                                            
  tanzu-buildpacks/nginx-lite@0.6.0                 
Group #6                                            
  tanzu-buildpacks/java-native-image-lite@6.18.1    
Group #7                                            
  tanzu-buildpacks/java-lite@6.27.0                 
Group #8                                            
  paketo-community/rust@0.18.0  

Workloadを作成します。 こちらの記事で作成したアプリを使用します。

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

stern でログを確認します。

stern -n demo hello-rust

次のようなログが流れ、rust buildpackでビルドされているログを確認できます。

+ hello-rust-build-1-build-pod › prepare


hello-rust-build-1-build-pod prepare Build reason(s): CONFIG
hello-rust-build-1-build-pod prepare CONFIG:
hello-rust-build-1-build-pod prepare  + env:
hello-rust-build-1-build-pod prepare  + - name: BP_OCI_SOURCE
hello-rust-build-1-build-pod prepare  +   value: main/88c425454ec5274ea2ba35441bc8d18c9aad6171
hello-rust-build-1-build-pod prepare  resources: {}
hello-rust-build-1-build-pod prepare  - source: {}
hello-rust-build-1-build-pod prepare  + source:
hello-rust-build-1-build-pod prepare  +   blob:
hello-rust-build-1-build-pod prepare  +     url: http://fluxcd-source-controller.flux-system.svc.cluster.local./gitrepository/demo/hello-rust/88c425454ec5274ea2ba35441bc8d18c9aad6171.tar.gz
hello-rust-build-1-build-pod prepare Loading secret for "ghcr.io" from secret "registry-credentials" at location "/var/build-secrets/registry-credentials"
hello-rust-build-1-build-pod prepare Loading cluster credential helpers
hello-rust-build-1-build-pod prepare Downloading fluxcd-source-controller.flux-system.svc.cluster.local./gitrepository/demo/hello-rust/88c425454ec5274ea2ba35441bc8d18c9aad6171.tar.gz...
hello-rust-build-1-build-pod prepare Successfully downloaded fluxcd-source-controller.flux-system.svc.cluster.local./gitrepository/demo/hello-rust/88c425454ec5274ea2ba35441bc8d18c9aad6171.tar.gz in path "/workspace"
- hello-rust-build-1-build-pod › prepare
+ hello-rust-build-1-build-pod › analyze
hello-rust-build-1-build-pod analyze Previous image with name "ghcr.io/making/hello-rust-demo" not found
- hello-rust-build-1-build-pod › analyze
+ hello-rust-build-1-build-pod › detect
hello-rust-build-1-build-pod detect 4 of 5 buildpacks participating
hello-rust-build-1-build-pod detect paketo-community/rustup    1.6.0
hello-rust-build-1-build-pod detect paketo-community/rust-dist 1.9.0
hello-rust-build-1-build-pod detect paketo-buildpacks/syft     1.16.0
hello-rust-build-1-build-pod detect paketo-community/cargo     0.7.0
- hello-rust-build-1-build-pod › detect
+ hello-rust-build-1-build-pod › restore
- hello-rust-build-1-build-pod › restore
+ hello-rust-build-1-build-pod › build
hello-rust-build-1-build-pod build 
hello-rust-build-1-build-pod build Paketo Rustup Buildpack 1.6.0
hello-rust-build-1-build-pod build   https://github.com/paketo-community/rustup
hello-rust-build-1-build-pod build   Build Configuration:
hello-rust-build-1-build-pod build     $BP_RUSTUP_ENABLED       true     use rustup to install Rust
hello-rust-build-1-build-pod build     $BP_RUSTUP_INIT_LIBC     gnu      libc implementation: gnu or musl
hello-rust-build-1-build-pod build     $BP_RUSTUP_INIT_VERSION  1        the rustup version
hello-rust-build-1-build-pod build     $BP_RUST_PROFILE         minimal  the Rust profile to install
hello-rust-build-1-build-pod build     $BP_RUST_TARGET                   an additional Rust target to install
hello-rust-build-1-build-pod build     $BP_RUST_TOOLCHAIN       stable   the Rust toolchain or version number to install
hello-rust-build-1-build-pod build   Rustup (GNU libc) 1.25.1: Contributing to layer
hello-rust-build-1-build-pod build     Downloading from https://static.rust-lang.org/rustup/archive/1.25.1/x86_64-unknown-linux-gnu/rustup-init
hello-rust-build-1-build-pod build     Verifying checksum
hello-rust-build-1-build-pod build     Copying to /layers/paketo-community_rustup/rustup-init-gnu/bin
hello-rust-build-1-build-pod build   Cargo: Contributing to layer
hello-rust-build-1-build-pod build   Rustup: Contributing to layer
hello-rust-build-1-build-pod build     Installing Rustup
hello-rust-build-1-build-pod build   Rust: Contributing to layer
hello-rust-build-1-build-pod build     Installing Rust
hello-rust-build-1-build-pod build       info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
hello-rust-build-1-build-pod build       info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
hello-rust-build-1-build-pod build       info: downloading component 'cargo'
hello-rust-build-1-build-pod build       info: downloading component 'rust-std'
hello-rust-build-1-build-pod build       info: downloading component 'rustc'
hello-rust-build-1-build-pod build       info: installing component 'cargo'
hello-rust-build-1-build-pod build       info: installing component 'rust-std'
hello-rust-build-1-build-pod build       info: installing component 'rustc'
      rust-build-1-build-pod build 
hello-rust-build-1-build-pod build         stable-x86_64-unknown-linux-gnu installed - rustc 1.63.0 (4b91a6ea7 2022-08-08)
hello-rust-build-1-build-pod build       
hello-rust-build-1-build-pod build       info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
hello-rust-build-1-build-pod build       info: checking for self-updates
hello-rust-build-1-build-pod build       info: component 'rust-std' for target 'x86_64-unknown-linux-gnu' is up to date
hello-rust-build-1-build-pod build 
hello-rust-build-1-build-pod build Rust Distribution Buildpack 1.9.0
hello-rust-build-1-build-pod build   https://github.com/paketo-community/rust-dist
hello-rust-build-1-build-pod build 
hello-rust-build-1-build-pod build Paketo Syft Buildpack 1.16.0
hello-rust-build-1-build-pod build   https://github.com/paketo-buildpacks/syft
hello-rust-build-1-build-pod build     Downloading from https://github.com/anchore/syft/releases/download/v0.53.4/syft_0.53.4_linux_amd64.tar.gz
hello-rust-build-1-build-pod build     Verifying checksum
hello-rust-build-1-build-pod build     Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
hello-rust-build-1-build-pod build 
hello-rust-build-1-build-pod build Rust Cargo Build Pack 0.7.0
hello-rust-build-1-build-pod build   https://github.com/paketo-community/cargo
hello-rust-build-1-build-pod build   Build Configuration:
hello-rust-build-1-build-pod build     $BP_CARGO_INSTALL_ARGS        --locked                              additional arguments to pass to Cargo install
hello-rust-build-1-build-pod build     $BP_CARGO_INSTALL_TOOLS                                             additional tools to be add with Cargo install
hello-rust-build-1-build-pod build     $BP_CARGO_INSTALL_TOOLS_ARGS                                        additional arguments to pass to Cargo install for tools
hello-rust-build-1-build-pod build     $BP_CARGO_TINI_DISABLED       false                                 Skip installing tini
hello-rust-build-1-build-pod build     $BP_CARGO_WORKSPACE_MEMBERS                                         the subset of workspace members for Cargo to install
hello-rust-build-1-build-pod build     $BP_DISABLE_SBOM              false                                 Skip running SBOM scan
hello-rust-build-1-build-pod build     $BP_EXCLUDE_FILES                                                   colon separated list of glob patterns, matched source files are removed
hello-rust-build-1-build-pod build     $BP_INCLUDE_FILES             static/*:templates/*:public/*:html/*  colon separated list of glob patterns, matched source files are included
hello-rust-build-1-build-pod build   Tini 0.19.0: Contributing to layer
hello-rust-build-1-build-pod build     Downloading from https://github.com/krallin/tini/releases/download/v0.19.0/tini-amd64
hello-rust-build-1-build-pod build     Verifying checksum
hello-rust-build-1-build-pod build     Copying to /layers/paketo-community_cargo/tini
hello-rust-build-1-build-pod build     Creating cached target directory /workspace/target
hello-rust-build-1-build-pod build   Rust Application: Contributing to layer
hello-rust-build-1-build-pod build     File modification times not restored
hello-rust-build-1-build-pod build     File modification times not restored
hello-rust-build-1-build-pod build     File modification times not restored
hello-rust-build-1-build-pod build     cargo install --locked --color=never --root=/layers/paketo-community_cargo/Cargo --path=.
hello-rust-build-1-build-pod build         Installing hello-rust v0.1.0 (/workspace)
hello-rust-build-1-build-pod build           Updating crates.io index
hello-rust-build-1-build-pod build        Downloading crates ...
hello-rust-build-1-build-pod build         Downloaded actix-codec v0.5.0
hello-rust-build-1-build-pod build         Downloaded bytestring v1.1.0
hello-rust-build-1-build-pod build         Downloaded local-waker v0.1.3
hello-rust-build-1-build-pod build         Downloaded local-channel v0.1.3
hello-rust-build-1-build-pod build         Downloaded sha1 v0.10.4
hello-rust-build-1-build-pod build         Downloaded actix-web v4.2.1
hello-rust-build-1-build-pod build         Downloaded firestorm v0.5.1
hello-rust-build-1-build-pod build         Downloaded actix-web-codegen v4.1.0
hello-rust-build-1-build-pod build         Downloaded language-tags v0.3.2
hello-rust-build-1-build-pod build         Downloaded cookie v0.16.0
hello-rust-build-1-build-pod build         Downloaded alloc-stdlib v0.2.2
hello-rust-build-1-build-pod build         Downloaded alloc-no-stdlib v2.0.4
hello-rust-build-1-build-pod build         Downloaded actix-rt v2.7.0
hello-rust-build-1-build-pod build         Downloaded actix-macros v0.2.3
hello-rust-build-1-build-pod build         Downloaded actix-utils v3.0.0
hello-rust-build-1-build-pod build         Downloaded actix-router v0.5.0
hello-rust-build-1-build-pod build         Downloaded actix-server v2.1.1
hello-rust-build-1-build-pod build         Downloaded actix-http v3.2.2
hello-rust-build-1-build-pod build         Downloaded derive_more v0.99.17
hello-rust-build-1-build-pod build         Downloaded actix-service v2.0.2
hello-rust-build-1-build-pod build         Downloaded cpufeatures v0.2.5
hello-rust-build-1-build-pod build         Downloaded typenum v1.15.0
hello-rust-build-1-build-pod build         Downloaded unicode-normalization v0.1.21
hello-rust-build-1-build-pod build         Downloaded zstd v0.11.2+zstd.1.5.2
hello-rust-build-1-build-pod build         Downloaded block-buffer v0.10.3
hello-rust-build-1-build-pod build         Downloaded autocfg v1.1.0
hello-rust-build-1-build-pod build         Downloaded cc v1.0.73
hello-rust-build-1-build-pod build         Downloaded zstd-safe v5.0.2+zstd.1.5.2
hello-rust-build-1-build-pod build         Downloaded once_cell v1.14.0
hello-rust-build-1-build-pod build         Downloaded zstd-sys v2.0.1+zstd.1.5.2
hello-rust-build-1-build-pod build         Downloaded httpdate v1.0.2
hello-rust-build-1-build-pod build         Downloaded itoa v1.0.3
hello-rust-build-1-build-pod build         Downloaded quote v1.0.21
hello-rust-build-1-build-pod build         Downloaded serde_json v1.0.85
hello-rust-build-1-build-pod build         Downloaded unicode-bidi v0.3.8
hello-rust-build-1-build-pod build         Downloaded miniz_oxide v0.5.4
hello-rust-build-1-build-pod build         Downloaded hashbrown v0.12.3
hello-rust-build-1-build-pod build         Downloaded h2 v0.3.14
hello-rust-build-1-build-pod build         Downloaded pin-utils v0.1.0
hello-rust-build-1-build-pod build         Downloaded scopeguard v1.1.0
hello-rust-build-1-build-pod build         Downloaded parking_lot v0.12.1
hello-rust-build-1-build-pod build         Downloaded signal-hook-registry v1.4.0
hello-rust-build-1-build-pod build         Downloaded socket2 v0.4.7
hello-rust-build-1-build-pod build         Downloaded libc v0.2.132
hello-rust-build-1-build-pod build         Downloaded encoding_rs v0.8.31
hello-rust-build-1-build-pod build         Downloaded tinyvec_macros v0.1.0
hello-rust-build-1-build-pod build         Downloaded smallvec v1.9.0
hello-rust-build-1-build-pod build         Downloaded tinyvec v1.6.0
hello-rust-build-1-build-pod build         Downloaded flate2 v1.0.24
hello-rust-build-1-build-pod build         Downloaded bytes v1.2.1
hello-rust-build-1-build-pod build         Downloaded tracing-core v0.1.29
hello-rust-build-1-build-pod build         Downloaded time v0.3.14
hello-rust-build-1-build-pod build         Downloaded time-macros v0.2.4
hello-rust-build-1-build-pod build         Downloaded slab v0.4.7
hello-rust-build-1-build-pod build         Downloaded rand_chacha v0.3.1
hello-rust-build-1-build-pod build         Downloaded mime v0.3.16
hello-rust-build-1-build-pod build         Downloaded paste v1.0.9
hello-rust-build-1-build-pod build         Downloaded idna v0.3.0
hello-rust-build-1-build-pod build         Downloaded rustc_version v0.4.0
hello-rust-build-1-build-pod build         Downloaded url v2.3.1
hello-rust-build-1-build-pod build         Downloaded jobserver v0.1.24
hello-rust-build-1-build-pod build         Downloaded proc-macro2 v1.0.43
hello-rust-build-1-build-pod build         Downloaded tokio v1.21.1
hello-rust-build-1-build-pod build         Downloaded brotli v3.3.4
hello-rust-build-1-build-pod build         Downloaded futures-util v0.3.24
hello-rust-build-1-build-pod build         Downloaded httparse v1.8.0
hello-rust-build-1-build-pod build         Downloaded unicode-ident v1.0.3
hello-rust-build-1-build-pod build         Downloaded fnv v1.0.7
hello-rust-build-1-build-pod build         Downloaded percent-encoding v2.2.0
hello-rust-build-1-build-pod build         Downloaded form_urlencoded v1.1.0
hello-rust-build-1-build-pod build         Downloaded bitflags v1.3.2
hello-rust-build-1-build-pod build         Downloaded base64 v0.13.0
hello-rust-build-1-build-pod build         Downloaded futures-task v0.3.24
hello-rust-build-1-build-pod build         Downloaded ahash v0.7.6
hello-rust-build-1-build-pod build         Downloaded num_threads v0.1.6
hello-rust-build-1-build-pod build         Downloaded ppv-lite86 v0.2.16
hello-rust-build-1-build-pod build         Downloaded tracing v0.1.36
hello-rust-build-1-build-pod build         Downloaded tokio-util v0.7.4
hello-rust-build-1-build-pod build         Downloaded syn v1.0.99
hello-rust-build-1-build-pod build         Downloaded ryu v1.0.11
hello-rust-build-1-build-pod build         Downloaded aho-corasick v0.7.19
hello-rust-build-1-build-pod build         Downloaded serde_urlencoded v0.7.1
hello-rust-build-1-build-pod build         Downloaded lock_api v0.4.8
hello-rust-build-1-build-pod build         Downloaded semver v1.0.13
hello-rust-build-1-build-pod build         Downloaded regex-syntax v0.6.27
hello-rust-build-1-build-pod build         Downloaded regex v1.6.0
hello-rust-build-1-build-pod build         Downloaded http v0.2.8
hello-rust-build-1-build-pod build         Downloaded rand_core v0.6.3
hello-rust-build-1-build-pod build         Downloaded memchr v2.5.0
hello-rust-build-1-build-pod build         Downloaded generic-array v0.14.6
hello-rust-build-1-build-pod build         Downloaded num_cpus v1.13.1
hello-rust-build-1-build-pod build         Downloaded digest v0.10.3
hello-rust-build-1-build-pod build         Downloaded cfg-if v1.0.0
hello-rust-build-1-build-pod build         Downloaded rand v0.8.5
hello-rust-build-1-build-pod build         Downloaded serde v1.0.144
hello-rust-build-1-build-pod build         Downloaded indexmap v1.9.1
hello-rust-build-1-build-pod build         Downloaded parking_lot_core v0.9.3
hello-rust-build-1-build-pod build         Downloaded log v0.4.17
hello-rust-build-1-build-pod build         Downloaded getrandom v0.2.7
hello-rust-build-1-build-pod build         Downloaded futures-core v0.3.24
hello-rust-build-1-build-pod build         Downloaded convert_case v0.4.0
hello-rust-build-1-build-pod build         Downloaded version_check v0.9.4
hello-rust-build-1-build-pod build         Downloaded pin-project-lite v0.2.9
hello-rust-build-1-build-pod build         Downloaded mio v0.8.4
hello-rust-build-1-build-pod build         Downloaded crypto-common v0.1.6
hello-rust-build-1-build-pod build         Downloaded crc32fast v1.3.2
hello-rust-build-1-build-pod build         Downloaded brotli-decompressor v2.3.2
hello-rust-build-1-build-pod build         Downloaded futures-sink v0.3.24
hello-rust-build-1-build-pod build         Downloaded adler v1.0.2
hello-rust-build-1-build-pod build          Compiling libc v0.2.132
hello-rust-build-1-build-pod build          Compiling cfg-if v1.0.0
hello-rust-build-1-build-pod build          Compiling autocfg v1.1.0
hello-rust-build-1-build-pod build          Compiling memchr v2.5.0
hello-rust-build-1-build-pod build          Compiling log v0.4.17
hello-rust-build-1-build-pod build          Compiling version_check v0.9.4
hello-rust-build-1-build-pod build          Compiling pin-project-lite v0.2.9
hello-rust-build-1-build-pod build          Compiling futures-core v0.3.24
hello-rust-build-1-build-pod build          Compiling once_cell v1.14.0
hello-rust-build-1-build-pod build          Compiling bytes v1.2.1
hello-rust-build-1-build-pod build          Compiling parking_lot_core v0.9.3
hello-rust-build-1-build-pod build          Compiling serde v1.0.144
hello-rust-build-1-build-pod build          Compiling smallvec v1.9.0
hello-rust-build-1-build-pod build          Compiling scopeguard v1.1.0
hello-rust-build-1-build-pod build          Compiling itoa v1.0.3
hello-rust-build-1-build-pod build          Compiling typenum v1.15.0
hello-rust-build-1-build-pod build          Compiling proc-macro2 v1.0.43
hello-rust-build-1-build-pod build          Compiling quote v1.0.21
hello-rust-build-1-build-pod build          Compiling unicode-ident v1.0.3
hello-rust-build-1-build-pod build          Compiling futures-task v0.3.24
hello-rust-build-1-build-pod build          Compiling futures-util v0.3.24
hello-rust-build-1-build-pod build          Compiling syn v1.0.99
hello-rust-build-1-build-pod build          Compiling percent-encoding v2.2.0
hello-rust-build-1-build-pod build          Compiling futures-sink v0.3.24
hello-rust-build-1-build-pod build          Compiling pin-utils v0.1.0
hello-rust-build-1-build-pod build          Compiling tinyvec_macros v0.1.0
hello-rust-build-1-build-pod build          Compiling crc32fast v1.3.2
hello-rust-build-1-build-pod build          Compiling zstd-safe v5.0.2+zstd.1.5.2
hello-rust-build-1-build-pod build          Compiling alloc-no-stdlib v2.0.4
hello-rust-build-1-build-pod build          Compiling fnv v1.0.7
hello-rust-build-1-build-pod build          Compiling local-waker v0.1.3
hello-rust-build-1-build-pod build          Compiling regex-syntax v0.6.27
hello-rust-build-1-build-pod build          Compiling paste v1.0.9
hello-rust-build-1-build-pod build          Compiling hashbrown v0.12.3
hello-rust-build-1-build-pod build          Compiling httparse v1.8.0
hello-rust-build-1-build-pod build          Compiling encoding_rs v0.8.31
hello-rust-build-1-build-pod build          Compiling adler v1.0.2
hello-rust-build-1-build-pod build          Compiling ppv-lite86 v0.2.16
hello-rust-build-1-build-pod build          Compiling cpufeatures v0.2.5
hello-rust-build-1-build-pod build          Compiling ryu v1.0.11
hello-rust-build-1-build-pod build          Compiling unicode-bidi v0.3.8
hello-rust-build-1-build-pod build          Compiling num_threads v0.1.6
hello-rust-build-1-build-pod build          Compiling bitflags v1.3.2
hello-rust-build-1-build-pod build          Compiling serde_json v1.0.85
hello-rust-build-1-build-pod build          Compiling convert_case v0.4.0
hello-rust-build-1-build-pod build          Compiling time-macros v0.2.4
hello-rust-build-1-build-pod build          Compiling firestorm v0.5.1
hello-rust-build-1-build-pod build          Compiling httpdate v1.0.2
hello-rust-build-1-build-pod build          Compiling base64 v0.13.0
hello-rust-build-1-build-pod build          Compiling mime v0.3.16
hello-rust-build-1-build-pod build          Compiling language-tags v0.3.2
hello-rust-build-1-build-pod build          Compiling lock_api v0.4.8
hello-rust-build-1-build-pod build          Compiling tokio v1.21.1
hello-rust-build-1-build-pod build          Compiling slab v0.4.7
hello-rust-build-1-build-pod build          Compiling indexmap v1.9.1
hello-rust-build-1-build-pod build          Compiling tracing-core v0.1.29
hello-rust-build-1-build-pod build          Compiling generic-array v0.14.6
hello-rust-build-1-build-pod build          Compiling ahash v0.7.6
hello-rust-build-1-build-pod build          Compiling cookie v0.16.0
hello-rust-build-1-build-pod build          Compiling bytestring v1.1.0
hello-rust-build-1-build-pod build          Compiling form_urlencoded v1.1.0
hello-rust-build-1-build-pod build          Compiling tinyvec v1.6.0
hello-rust-build-1-build-pod build          Compiling alloc-stdlib v0.2.2
hello-rust-build-1-build-pod build          Compiling http v0.2.8
hello-rust-build-1-build-pod build          Compiling actix-utils v3.0.0
hello-rust-build-1-build-pod build          Compiling miniz_oxide v0.5.4
hello-rust-build-1-build-pod build          Compiling brotli-decompressor v2.3.2
hello-rust-build-1-build-pod build          Compiling unicode-normalization v0.1.21
hello-rust-build-1-build-pod build          Compiling tracing v0.1.36
hello-rust-build-1-build-pod build          Compiling aho-corasick v0.7.19
hello-rust-build-1-build-pod build          Compiling jobserver v0.1.24
hello-rust-build-1-build-pod build          Compiling socket2 v0.4.7
hello-rust-build-1-build-pod build          Compiling signal-hook-registry v1.4.0
hello-rust-build-1-build-pod build          Compiling mio v0.8.4
hello-rust-build-1-build-pod build          Compiling getrandom v0.2.7
hello-rust-build-1-build-pod build          Compiling num_cpus v1.13.1
hello-rust-build-1-build-pod build          Compiling time v0.3.14
hello-rust-build-1-build-pod build          Compiling actix-service v2.0.2
hello-rust-build-1-build-pod build          Compiling flate2 v1.0.24
hello-rust-build-1-build-pod build          Compiling brotli v3.3.4
hello-rust-build-1-build-pod build          Compiling idna v0.3.0
hello-rust-build-1-build-pod build          Compiling serde_urlencoded v0.7.1
hello-rust-build-1-build-pod build          Compiling regex v1.6.0
hello-rust-build-1-build-pod build          Compiling cc v1.0.73
hello-rust-build-1-build-pod build          Compiling parking_lot v0.12.1
hello-rust-build-1-build-pod build          Compiling rand_core v0.6.3
hello-rust-build-1-build-pod build          Compiling crypto-common v0.1.6
hello-rust-build-1-build-pod build          Compiling block-buffer v0.10.3
hello-rust-build-1-build-pod build          Compiling url v2.3.1
hello-rust-build-1-build-pod build          Compiling local-channel v0.1.3
hello-rust-build-1-build-pod build          Compiling actix-router v0.5.0
hello-rust-build-1-build-pod build          Compiling zstd-sys v2.0.1+zstd.1.5.2
hello-rust-build-1-build-pod build          Compiling rand_chacha v0.3.1
hello-rust-build-1-build-pod build          Compiling digest v0.10.3
hello-rust-build-1-build-pod build          Compiling derive_more v0.99.17
hello-rust-build-1-build-pod build          Compiling actix-macros v0.2.3
hello-rust-build-1-build-pod build          Compiling actix-web-codegen v4.1.0
hello-rust-build-1-build-pod build          Compiling rand v0.8.5
hello-rust-build-1-build-pod build          Compiling sha1 v0.10.4
hello-rust-build-1-build-pod build          Compiling tokio-util v0.7.4
hello-rust-build-1-build-pod build          Compiling actix-rt v2.7.0
hello-rust-build-1-build-pod build          Compiling h2 v0.3.14
hello-rust-build-1-build-pod build          Compiling actix-codec v0.5.0
hello-rust-build-1-build-pod build          Compiling actix-server v2.1.1
hello-rust-build-1-build-pod build          Compiling zstd v0.11.2+zstd.1.5.2
hello-rust-build-1-build-pod build          Compiling actix-http v3.2.2
hello-rust-build-1-build-pod build          Compiling actix-web v4.2.1
hello-rust-build-1-build-pod build          Compiling hello-rust v0.1.0 (/workspace)
hello-rust-build-1-build-pod build           Finished release [optimized] target(s) in 2m 17s
hello-rust-build-1-build-pod build         Installing /layers/paketo-community_cargo/Cargo/bin/hello-rust
hello-rust-build-1-build-pod build          Installed package `hello-rust v0.1.0 (/workspace)` (executable `hello-rust`)
hello-rust-build-1-build-pod build   Removing source code
- hello-rust-build-1-build-pod › build
+ hello-rust-build-1-build-pod › export
hello-rust-build-1-build-pod export Adding layer 'paketo-community/cargo:Cargo'
hello-rust-build-1-build-pod export Adding layer 'paketo-community/cargo:tini'
hello-rust-build-1-build-pod export Adding layer 'launch.sbom'
hello-rust-build-1-build-pod export Adding 1/1 app layer(s)
hello-rust-build-1-build-pod export Adding layer 'launcher'
hello-rust-build-1-build-pod export Adding layer 'config'
hello-rust-build-1-build-pod export Adding layer 'process-types'
hello-rust-build-1-build-pod export Adding label 'io.buildpacks.lifecycle.metadata'
hello-rust-build-1-build-pod export Adding label 'io.buildpacks.build.metadata'
hello-rust-build-1-build-pod export Adding label 'io.buildpacks.project.metadata'
hello-rust-build-1-build-pod export Setting default process type 'hello-rust'
hello-rust-build-1-build-pod export Saving tap11046.azurecr.io/supply-chain/hello-rust-demo...
hello-rust-build-1-build-pod export *** Images (sha256:bbede62f5f541d42339451d0f5ebcf24805fecff1560810cffabad03a06699ec):
hello-rust-build-1-build-pod export       tap11046.azurecr.io/supply-chain/hello-rust-demo
hello-rust-build-1-build-pod export       tap11046.azurecr.io/supply-chain/hello-rust-demo:b1.20220914.052504
hello-rust-build-1-build-pod export Adding cache layer 'paketo-community/rustup:Cargo'
hello-rust-build-1-build-pod export Adding cache layer 'paketo-community/rustup:Rust'
hello-rust-build-1-build-pod export Adding cache layer 'paketo-community/rustup:Rustup'
hello-rust-build-1-build-pod export Adding cache layer 'paketo-community/rustup:rustup-init-gnu'
hello-rust-build-1-build-pod export Adding cache layer 'paketo-buildpacks/syft:syft'
hello-rust-build-1-build-pod export Adding cache layer 'paketo-community/cargo:Cargo'
hello-rust-build-1-build-pod export Adding cache layer 'paketo-community/cargo:Cargo Cache'
hello-rust-build-1-build-pod export Adding cache layer 'cache.sbom'
- hello-rust-build-1-build-pod › export
+ hello-rust-config-writer-774bk-pod › step-main
hello-rust-config-writer-774bk-pod step-main ++ mktemp -d
...
hello-rust-config-writer-774bk-pod step-main + export IMGPKG_ENABLE_IAAS_AUTH=false
hello-rust-config-writer-774bk-pod step-main + IMGPKG_ENABLE_IAAS_AUTH=false
hello-rust-config-writer-774bk-pod step-main + imgpkg push -b tap11046.azurecr.io/supply-chain/hello-rust-demo-bundle:a01b4237-71ba-402e-a928-da934bd6ffb2 -f .
- hello-rust-config-writer-774bk-pod › step-main
+ hello-rust-00001-deployment-f94b95dbf-cqvkh › workload
+ hello-rust-00001-deployment-f94b95dbf-cqvkh › queue-proxy
hello-rust-00001-deployment-f94b95dbf-cqvkh queue-proxy {"severity":"INFO","timestamp":"2022-09-14T05:29:07.838154919Z","caller":"logging/config.go:116","message":"Successfully created the logger."}
hello-rust-00001-deployment-f94b95dbf-cqvkh queue-proxy {"severity":"INFO","timestamp":"2022-09-14T05:29:07.83821502Z","caller":"logging/config.go:117","message":"Logging level set to: info"}
hello-rust-00001-deployment-f94b95dbf-cqvkh queue-proxy {"level":"info","ts":1663133347.8387012,"logger":"fallback","caller":"metrics/metrics_worker.go:76","msg":"Flushing the existing exporter before setting up the new exporter."}
hello-rust-00001-deployment-f94b95dbf-cqvkh queue-proxy {"level":"info","ts":1663133347.8388586,"logger":"fallback","caller":"metrics/prometheus_exporter.go:51","msg":"Created Prometheus exporter with config: &{knative.dev/internal/serving revision prometheus 5000000000 <nil>  false 9091 0.0.0.0}. Start the server for Prometheus exporter."}
hello-rust-00001-deployment-f94b95dbf-cqvkh queue-proxy {"level":"info","ts":1663133347.8388944,"logger":"fallback","caller":"metrics/metrics_worker.go:91","msg":"Successfully updated the metrics exporter; old config: <nil>; new config &{knative.dev/internal/serving revision prometheus 5000000000 <nil>  false 9091 0.0.0.0}"}

次のコマンドでデプロイされたアプリを確認します。

$ tanzu apps workload get -n demo hello-rust
---
# hello-rust: Ready
---
Source
type:     git
url:      https://github.com/making/hello-rust
branch:   main

Supply Chain
name:          source-to-url
last update:   87s
ready:         True

RESOURCE          READY   TIME
source-provider   True    5m6s
deliverable       True    5m13s
image-builder     True    104s
config-provider   True    97s
app-config        True    97s
config-writer     True    87s

Issues
No issues reported.

Pods
NAME                                          STATUS      RESTARTS   AGE
hello-rust-00001-deployment-f94b95dbf-cqvkh   Running     0          65s
hello-rust-build-1-build-pod                  Succeeded   0          5m5s
hello-rust-config-writer-774bk-pod            Succeeded   0          97s

Knative Services
NAME         READY   URL
hello-rust   Ready   https://hello-rust-demo.20-89-141-216.sslip.io

To see logs: "tanzu apps workload tail hello-rust --namespace demo"

アプリにアクセスします。

$ curl -k https://hello-rust-demo.20-89-141-216.sslip.io
Hello world!

$ curl -k https://hello-rust-demo.20-89-141-216.sslip.io/echo -d 'Hello'
Hello

$ curl -k https://hello-rust-demo.20-89-141-216.sslip.io/hey
Hey there!

full dependenciesを使用している場合

full dependenciesのインストール方法はこちらの記事を参照してください。

次のoverlayファイルを作成します。

cat <<EOF > full-tbs-deps-add-rust-builder.yaml
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"metadata":{"name":"dependency-updater"}, "kind": "TanzuNetDependencyUpdater"})
---
spec:
  inlineDescriptor:
    clusterStores:
    #@overlay/match by="name", missing_ok=True
    - name: default
      sources:
      #@overlay/append
      - image: docker.io/paketocommunity/rust:0.18.0
    clusterBuilders:
    #@overlay/match by="name", missing_ok=True
    - name: base
      order:
      #@overlay/append
      - group:
        - id: paketo-community/rust
    #@overlay/match by="name", missing_ok=True
    - name: full
      order:
      #@overlay/append
      - group:
        - id: paketo-community/rust
    #@overlay/match by="name", missing_ok=True
    - name: tiny
      order:
      #@overlay/append
      - group:
        - id: paketo-community/rust
EOF

次のコマンドでoverlayファイルのSecretを作成します。

kubectl -n tap-install create secret generic full-tbs-deps-add-rust-builder \
  -o yaml \
  --dry-run=client \
  --from-file=full-tbs-deps-add-rust-builder.yaml \
  | kubectl apply -f-

次のコマンドでoverlayを適用します。

kubectl -n tap-install annotate packageinstalls full-tbs-deps ext.packaging.carvel.dev/ytt-paths-from-secret-name.0=full-tbs-deps-add-rust-builder --overwrite=true

lite dependencies同様、Builderの更新の進捗は次のログを見ることで確認できます。

$ kubectl logs -n build-service deploy/dependency-updater-controller -f

lite dependencies同様、次のコマンドでClusterStoreやClusterBuilderにrust buildpackが追加されていることを確認します。

$ kp clusterstore status default 
Status:    Ready

BUILDPACKAGE ID                       VERSION    HOMEPAGE
paketo-buildpacks/procfile            5.1.2      https://github.com/paketo-buildpacks/procfile
paketo-community/rust                 0.18.0     https://github.com/paketo-community/rust
tanzu-buildpacks/dotnet-core          1.14.3     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-dotnet-core-dotnet-core-buildpack.html
tanzu-buildpacks/go                   1.12.0     https://docs.pivotal.io/tanzu-buildpacks/go/go-buildpack.html
tanzu-buildpacks/java                 6.36.0     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-java-java-buildpack.html
tanzu-buildpacks/java                 6.27.0     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-java-java-buildpack.html
tanzu-buildpacks/java-native-image    6.18.1     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-java-java-buildpack.html
tanzu-buildpacks/java-native-image    6.24.1     https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-java-java-buildpack.html
tanzu-buildpacks/nginx                0.6.0      https://docs.pivotal.io/tanzu-buildpacks/nginx/nginx-buildpack.html
tanzu-buildpacks/nodejs               1.14.2     https://docs.pivotal.io/tanzu-buildpacks/nodejs/nodejs-buildpack.html
tanzu-buildpacks/php                  1.0.1      https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-php-php-buildpack.html
tanzu-buildpacks/python               2.0.0      
tanzu-buildpacks/web-servers          0.1.0  
$ kp clusterbuilder status base
...

DETECTION ORDER                                
Group #1                                       
  tanzu-buildpacks/dotnet-core@1.14.3          
Group #2                                       
  tanzu-buildpacks/nodejs@1.14.2               
Group #3                                       
  tanzu-buildpacks/go@1.12.0                   
Group #4                                       
  tanzu-buildpacks/python@2.0.0                
Group #5                                       
  tanzu-buildpacks/nginx@0.6.0                 
Group #6                                       
  tanzu-buildpacks/java-native-image@6.24.1    
Group #7                                       
  tanzu-buildpacks/java@6.36.0                 
Group #8                                       
  paketo-buildpacks/procfile@5.2.1             
Group #9                                       
  paketo-community/rust@0.18.0  
$ kp clusterbuilder status full
...

DETECTION ORDER                                
Group #1                                       
  tanzu-buildpacks/dotnet-core@1.14.3          
Group #2                                       
  tanzu-buildpacks/nodejs@1.14.2               
Group #3                                       
  tanzu-buildpacks/go@1.12.0                   
Group #4                                       
  tanzu-buildpacks/python@2.0.0                
Group #5                                       
  tanzu-buildpacks/php@1.0.1                   
Group #6                                       
  tanzu-buildpacks/web-servers@0.1.0           
Group #7                                       
  tanzu-buildpacks/java-native-image@6.24.1    
Group #8                                       
  tanzu-buildpacks/java@6.36.0                 
Group #9                                       
  paketo-buildpacks/procfile@5.2.1             
Group #10                                      
  paketo-community/rust@0.18.0 
$ kp clusterbuilder status tiny
...

DETECTION ORDER                                
Group #1                                       
  tanzu-buildpacks/go@1.12.0                   
Group #2                                       
  tanzu-buildpacks/java-native-image@6.24.1    
Group #3                                       
  paketo-buildpacks/procfile@5.2.1             
Group #4                                       
  paketo-community/rust@0.18.0

lite dependencies同様、次のコマンドでWorkloadを作成します。

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