Successfully reported this slideshow.
Your SlideShare is downloading. ×

DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 44 Ad

DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf

Download to read offline

Skaffold V2 擴充套件了 Skaffold 支援的平臺和架構,引入了 Cloud Run 作為支援的部署器,現在支援從 ARM 和 x86 架構構建並部署到 ARM 和 x86 架構。Skaffold V2 還提供了對 CI/CD 和 GitOps 工作流程的增強支援,引入了 skaffold render、verify 和 kpt 整合。最重要的是,所有現有的 Skaffold 配置都與 Skaffold V2 完全相容,從 V1 升級就像執行 skaffold fix 一樣容易

Skaffold V2 擴充套件了 Skaffold 支援的平臺和架構,引入了 Cloud Run 作為支援的部署器,現在支援從 ARM 和 x86 架構構建並部署到 ARM 和 x86 架構。Skaffold V2 還提供了對 CI/CD 和 GitOps 工作流程的增強支援,引入了 skaffold render、verify 和 kpt 整合。最重要的是,所有現有的 Skaffold 配置都與 Skaffold V2 完全相容,從 V1 升級就像執行 skaffold fix 一樣容易

Advertisement
Advertisement

More Related Content

More from KAI CHU CHUNG (17)

Recently uploaded (20)

Advertisement

DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf

  1. 1. Taipei KAI CHU CHUNG I/T Specialist, IBM Skaffold 2 Deep Dive
  2. 2. KAI CHU CHUNG Cloud GDE GDG Cloud Taipei co-organizers I/T Specialist, IBM @CageChung https://kaichu.io
  3. 3. Agenda 1. Overview 2. Pipeline Stages 3. Q & A SKAFFOLD
  4. 4. Overview
  5. 5. “Skaffold is a command line tool that facilitates continuous development for Kubernetes applications. You can iterate on your application source code locally then deploy to local or remote Kubernetes clusters. Skaffold handles the workflow for building, pushing and deploying your application. It also provides building blocks and describe customizations for a CI/CD pipeline.”
  6. 6. 2018 2019 2020 2021 2022 V2.0.0 Oct 21, 2022 V1.1.0 Dec 21, 2019 v0.1.0 Mar 6, 2018 2023 V1.39.2 Aug 17,2022 V2.0.2 Nov 15, 2022 Timeline latest v0.41.0 Oct 25, 2019 46 Releases 72 Releases
  7. 7. Installing Skaffold Managed IDE ● CLOUD CODE ○ VSCode ○ IntellJ ● GOOGLE CLOUD SHELL ● Cloud Workstation
  8. 8. Quickstart - Standalone Mac # For macOS on x86_64 (amd64) curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-darwin-amd64 && sudo install skaffold /usr/local/bin/ # For macOS on ARMv8 (arm64) curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-darwin-arm64 && sudo install skaffold /usr/local/bin/ docker gcloud gcloud components install skaffold docker run gcr.io/k8s-skaffold/skaffold:latest skaffold <command> steps: - name: gcr.io/k8s-skaffold/skaffold:v1.21.0 entrypoint: bash args: - -exc - | gcloud container clusters get-credentials $_CLOUDSDK_CONTAINER_CLUSTER --zone $_CLOUDSDK_COMPUTE_ZO
  9. 9. Quickstart - VSCode / IntellJ
  10. 10. Quickstart - Cloud Shell
  11. 11. Quickstart - Cloud Workstation Cloud Code Easier to create apps in Google Cloud
  12. 12. Getting Started With Your Project Guides skaffold dev Debugging With Skaffold Continuous Delivery Managing ARM workloads [NEW] Guides | Skaffold - https://skaffold.dev/docs/workflows/
  13. 13. Guides - skaffold dev skaffold dev enables continuous local development on an application. While in dev mode, Skaffold will watch an application’s source files, and when it detects changes, will rebuild your images (or sync files to your running containers), push any new images, test built images, and redeploy the application to your cluster. File Sync Build Test Deploy Dev loop Code Change ? Yes
  14. 14. Guides - skaffold debug Skaffold lets you set breakpoints and step through your application, even when deployed to remote Kubernetes clusters, as if the code were running locally on your machine ● Go 1.13+ (runtime ID: go) using Delve ● NodeJS (runtime ID: nodejs) using the NodeJS Inspector (Chrome DevTools) ● Java and JVM languages (runtime ID: jvm) using JDWP ● Python 3.5+ (runtime ID: python) using debugpy (Debug Adapter Protocol) or pydevd ● .NET Core (runtime ID: netcore) using vsdbg (only for VS Code)
  15. 15. Guides - skaffold debug: Go Labels: app=square pod-template-hash=758577b69b Annotations: debug.cloud.google.com/config: {"square":{"artifact":"square","runtime":"go", "workingDir":"/workspace","ports":{"dlv":56268}}} ... Init Containers: install-go-debug-support: Container ID: containerd://dc45badbf94a6f3b61d8c1e3353bfe3e782ed3783990e43b8649a97aa813fe85 Image: gcr.io/k8s-skaffold/skaffold-debug-support/go Image ID: gcr.io/k8s-skaffold/skaffold-debug-support/go@sha256:da1f2d0e00463ec8c2040eb9b8cb939de15 Port: <none> Host Port: <none> State: Terminated Reason: Completed Exit Code: 0 Started: Tue, 29 Nov 2022 17:27:49 +0800 Finished: Tue, 29 Nov 2022 17:27:49 +0800 Ready: True Restart Count: 0 Environment: <none> Mounts: /dbg from debugging-support-files (rw)
  16. 16. Guides - skaffold debug: Go Cont. Containers: square: Container ID: containerd://cdc99f343c2a129341aa8615d988d7ddc4b0c7ca9963b13e0839e9d4b9721a97 Image: gcr.io/gcp-10-mins/square:latest@sha256:53bddc80b70b9731ae56bc27e228fcf15d4f2ef9ce4a06469 Image ID: gcr.io/gcp-10-mins/square@sha256:53bddc80b70b9731ae56bc27e228fcf15d4f2ef9ce4a06469761c4c5 Port: 56268/TCP Host Port: 0/TCP Command: /cnb/lifecycle/launcher Args: -- /dbg/go/bin/dlv exec --headless --continue --accept-multiclient --listen=:56268 --api-version=2 /layers/google.go.build/bin/main State: Running Started: Tue, 29 Nov 2022 17:27:52 +0800 Ready: True Restart Count: 0 Environment: QS_GRPC_PORT: 10021
  17. 17. Guides - skaffold debug: Go Cont. { "version": "0.2.0", "configurations": [ { "name": "Skaffold Debug", "type": "go", "request": "attach", "mode": "remote", "host": "localhost", "port": 56268, "substitutePath": [ { "from": "${workspaceFolder}", "to": "/go", }, ], } ] }
  18. 18. Guides - Continuous Delivery Skaffold provides several features and sub-command “building blocks” that make it very useful for integrating with (or creating entirely new) CI/CD pipelines. ● skaffold build - build, tag and push artifacts to a registry ● skaffold deploy - deploy built artifacts to a cluster ● skaffold render - export the transformed Kubernetes manifests ● skaffold apply - send hydrated Kubernetes manifests to the API server to create resources on the target cluster $ skaffold build -f skaffold-v2.yaml --default-repo gcr.io/gcp-10-mins --file-output build.json $ skaffold deploy --build-artifacts=./build.json {"builds":[{"imageName":"square","tag":"gcr.io/gcp-10-mins/square:latest@sha256:665db6a58565ee192093df04470 ea86705d8b33b69c1e7f6d7a6ea07e18491f6"}]}
  19. 19. Guides - Continuous Delivery Cont. Skaffold allows separating the generation of fully-hydrated Kubernetes manifests from the actual deployment of those manifests, using the skaffold render and skaffold apply commands. $ skaffold render -f skaffold-v2.yaml --default-repo gcr.io/gcp-10-mins > render.yaml $ skaffold render -f skaffold-v2.yaml apply render.yaml beta
  20. 20. Guides - Managing ARM workloads Skaffold will check the active Kubernetes cluster node architecture and provide that as an argument to the respective image builder. If the cluster has multiple architecture nodes, then Skaffold will also create appropriate Kubernetes affinity rules so that the Kubernetes Pods with these images are assigned to matching architecture nodes. New $ skaffold run -f skaffold-v2.yaml --default-repo gcr.io/gcp-10-mins --cache-artifacts=false Generating tags... - square -> gcr.io/gcp-10-mins/square:latest Starting build... Building [square]... Target platforms: [linux/amd64] v1: Pulling from buildpacks/builder Digest: sha256:de4d669b82419307072df7b35c3c9a81aca35e308be2bac5ec4ca7dbcba31f24 Status: Image is up to date for gcr.io/buildpacks/builder:v1 GKE Node
  21. 21. Architecture and Design | Skaffold - https://skaffold.dev/docs/design/ Architecture
  22. 22. Architecture and Design | Skaffold - https://skaffold.dev/docs/design/ Architecture - Cloud Build / Helm
  23. 23. Pipeline Stages
  24. 24. Skaffold Pipeline Stages | Skaffold - https://skaffold.dev/docs/pipeline-stages/ Skaffold Pipeline Stages
  25. 25. Release v2.0.0 Release · GoogleContainerTools/skaffold - https://github.com/GoogleContainerTools/skaffold/releases/tag/v2.0.0 Highlights & New Features ● 💻 Support for deploying to ARM, X86 or Multi-Arch K8s clusters from your x86 or ARM machine ● 👟 New Cloud Run Deployer brings the power of Skaffold to Google Clouds serverless container runtime ● 📜 Skaffold render phase has been split from deploy phase providing increased granularity of control for GitOps workflows ● 🚦New Skaffold verify phase enables improved testing capabilities making Skaffold even better as a CI/CD tool ● ⚙ Tighter integration with kpt lets you more dynamically manage large amounts of configuration and keep it in sync
  26. 26. Upgrading from Skaffold v1 to Skaffold v2 [NEW] | Skaffold - https://skaffold.dev/docs/upgrading/ 1. skaffold deploy → skaffold render + skaffold deploy 2. New schema version: v3alpha1 3. Few skaffold v1 features are no longer support or require manual changes for v2.0.0-beta3 include 4. there are currently no known other regressions when migrating from skaffold v1 -> v2 but areas that are most likely to have possible issues/incompitibility Upgrading from Skaffold v1 to Skaffold v2 $ cat skaffold.yaml | head -1 apiVersion: skaffold/v2beta29 $ skaffold fix apiVersion: skaffold/v3alpha1 kind: Config build: artifacts: - image: skaffold-example manifests: rawYaml: - k8s-* deploy: kubectl: {}
  27. 27. Init skaffold init helps you get started using Skaffold by running you through a wizard and generating the required skaffold.yaml file in the root of your project directory. The generated skaffold.yaml defines your build and deploy config. apiVersion: skaffold/v4beta1 kind: Config metadata: name: '-' build: artifacts: - image: gcr.io/gcp-10-mins/add buildpacks: builder: gcr.io/buildpacks/builder:v1 manifests: helm: flags: upgrade: - --install releases: - name: square chartPath: deployments/square setValues: square.image: square setValueTemplates: square.env.QS_LOG_LEVEL: "{{.QS_LOG_LEVEL}}" deploy: helm: {}
  28. 28. Build Local Build In Cluster Build Remote on Google Cloud Build Dockerfile Yes Yes Yes Jib Maven and Gradle Yes - Yes Cloud Native Buildpacks Yes - Yes Bazel Yes - - ko Yes - Yes Custom Script Yes Yes - The build section in the Skaffold configuration file, skaffold.yaml, controls how artifacts are built. To use a specific tool for building artifacts, add the value representing the tool and options for using that tool to the build section.
  29. 29. Build - Cloud Native Buildpacks apiVersion: skaffold/v4beta1 kind: Config metadata: name: '-' build: artifacts: - image: square buildpacks: builder: gcr.io/buildpacks/builder:v1 env: - GOOGLE_BUILDABLE=cmd/square/main.go - GOOGLE_RUNTIME_VERSION=1.14 dependencies: paths: - cmd/square/main.go - internal/app/square/** - internal/pkg/** tagPolicy: sha256: {} local: push: true Gdg cloud taipei ddt meetup #53 buildpack - https://www.slideshare.net/cagechung/gdg-cloud-taipei-ddt-meetup-53-buildpack
  30. 30. [Skaffold 2.0 Documentation | Skaffold](https://skaffold.dev/docs/) Build - Cloud Native Buildpacks Cont. $ QS_LOG_LEVEL=debug skaffold run --default-repo gcr.io/gcp-10-mins -f skaffold-v2.yaml Generating tags... - square -> gcr.io/gcp-10-mins/square:latest ... Target platforms: [linux/amd64] v1: Pulling from buildpacks/builder Digest: sha256:de4d669b82419307072df7b35c3c9a81aca35e308be2bac5ec4ca7dbcba31f24 Status: Image is up to date for gcr.io/buildpacks/builder:v1 ... ===> BUILDING [builder] === Go - Runtime (google.go.runtime@0.9.1) === [builder] Using runtime version from GOOGLE_RUNTIME_VERSION: 1.14 [builder] === Go - Gomod (google.go.gomod@0.9.0) === [builder] -------------------------------------------------------------------------------- [builder] Running "go mod download (GOPATH=/layers/google.go.gomod/gopath GO111MODULE=on)" [builder] Done "go mod download (GOPATH=/layers/google.go.gomod/gopath GO111..." (536.9738ms) [builder] === Go - Build (google.go.build@0.9.0) === [builder] -------------------------------------------------------------------------------- [builder] Running "go build -o /layers/google.go.build/bin/main cmd/square/main.go (GOCACHE=/layers/google.go.build/gocache)" [builder] Done "go build -o /layers/google.go.build/bin/main cmd/square/main..." (7.2431905s) [builder] === Utils - Label Image (google.utils.label@0.0.2) ===
  31. 31. Cloud Run button
  32. 32. Deploy - Google Cloud Run alpha manifests must be valid Cloud Run services, using the serving.knative.dev/v1 schema googleapi: Error 400: Registry image path like [region.]gcr.io/repo-path[:tag and/or @digest] apiVersion: skaffold/v4beta1 kind: Config build: artifacts: - image: gokit-add-cloud-run buildpacks: builder: "gcr.io/buildpacks/builder:v1" dependencies: paths: - cmd/add/main.go - internal/** env: - GOOGLE_BUILDABLE=cmd/add/main.go tagPolicy: sha256: {} local: push: true profiles: - name: cloud-run manifests: rawYaml: - manifests/cloud-run.yaml deploy: cloudrun: projectid: gcp-10-mins region: asia-east1 New
  33. 33. [Skaffold 2.0 Documentation | Skaffold](https://skaffold.dev/docs/) Deploy - Google Cloud Run Cont. New $ skaffold --default-repo gcr.io/gcp-10-mins run -p cloud-run WARN[0001] failed to detect active kubernetes cluster node platform. Specify the correct build platform in the `skaffold.yaml` file or using the `--platform` flag subtask=-1 task=DevLoop Generating tags... - gokit-add-cloud-run -> gcr.io/gcp-10-mins/gokit-add-cloud-run:latest .... Build [gokit-add-cloud-run] succeeded Starting test... Tags used in deployment: - gokit-add-cloud-run -> gcr.io/gcp-10-mins/gokit-add-cloud-run:latest@sha256:acf05cfabd250d6d576e6b0b8aaa1f18ae3fd79d99e16fa1a5a3be 473f6eecb6 Starting deploy... Deploying Cloud Run service: gokit-add-cloud-run gokit-add-cloud-run: Service starting: Deploying Revision. Waiting on revision gokit-add-cloud-run-00001-wyq. Cloud Run Service gokit-add-cloud-run finished: Service started. 0/1 deployment(s) still pending You can also run [skaffold run --tail] to get the logs
  34. 34. Deploy - Helm Update No more `artifactOverrides` or `imageStrategy` Skaffold no longer requires the intricate configuring of artifactOverrides or imageStrategy fields. See docs here on how old artifactOverrides and imageStrategy values translate to setValues entires in the latest Skaffold schemas (apiVersion: skaffold/v3alpha1 or skaffold binary version v2.0.0 onwards) Note (manifest.helm.*) and the helm deployer (deploy.helm.*) is the use of helm template vs helm install
  35. 35. Deploy - Helm Cont. Update deploy: helm: flags: upgrade: - --install releases: - name: square chartPath: ./deployments/helm/square artifactOverrides: square.image: gcr.io/gcp-10-mins/square setValues: square.env.QS_LOG_LEVEL: info manifests: helm: flags: upgrade: - --install releases: - name: square chartPath: deployments/square setValues: square.image: square setValueTemplates: square.env.QS_LOG_LEVEL: "{{.QS_LOG_LEVEL}}" deploy: helm: {} v1 v2
  36. 36. Deploy - Helm Cont. Update $ QS_LOG_LEVEL=debug skaffold run --default-repo gcr.io/gcp-10-mins -f skaffold-v2.yaml Generating tags... - square -> gcr.io/gcp-10-mins/square:latest Checking cache... - square: Found Remotely Starting test... Tags used in deployment: - square -> gcr.io/gcp-10-mins/square:latest@sha256:36ff3a328a97a4ae13937516b697d63fc5d89621d69fba255683acaad6fa5eb0 Starting deploy... Release "square" has been upgraded. Happy Helming! NAME: square LAST DEPLOYED: Tue Nov 29 08:21:19 2022 NAMESPACE: default STATUS: deployed REVISION: 4 TEST SUITE: None Waiting for deployments to stabilize... - deployment/square: creating container square - pod/square-59ddb57855-cvt4b: creating container square - deployment/square is ready. Deployments stabilized in 11.323 seconds You can also run [skaffold run --tail] to get the logs
  37. 37. Render New the Skaffold renderer renders the final Kubernetes manifests: Skaffold replaces untagged image names in the Kubernetes manifests with the final tagged image names. It also might go through the extra intermediate step of expanding templates (for helm) or calculating overlays (for kustomize) ● rawYaml - use this if you don’t currently use a rendering tool ● helm ● kpt ● kustomize
  38. 38. Render - Helm New apiVersion: v1 kind: Service metadata: name: square Spec: type: LoadBalancer ports: - name: http port: 80 targetPort: 10020 - name: grpc port: 8000 targetPort: 10021 selector: app: square apiVersion: apps/v1 kind: Deployment metadata: name: square spec: replicas: 1 selector: matchLabels: app: square template: metadata: labels: app: square spec: containers: - env: - name: QS_GRPC_PORT value: "10021" - name: QS_HTTP_PORT value: "10020" - name: QS_LOG_LEVEL value: debug image: gcr.io/gcp-10-mins/square:latest@sha256:ecc0ee10 name: square $ QS_LOG_LEVEL=debug skaffold render -f skaffold-v2.yaml --default-repo gcr.io/gcp-10-mins
  39. 39. Resources
  40. 40. Known issues Cloud Code (v1.20.4, Nov 2022) not support Skaffold 2 yet, current build-in skaffold version is v1.39.3
  41. 41. DevFest 2022 - Cloud Workstation Introduction TaiChung - https://www.slideshare.net/cagechung/devfest-2022-cloud-workstation-introduction-taichungpdf
  42. 42. Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐 - https://www.slideshare.net/cagechung/coscup-x-ruby-conf-tw-2021-google-cloud-buildpacks
  43. 43. Devfest 2021' - Artifact Registry Introduction (Taipei) - https://www.slideshare.net/cagechung/devfest-2021-artifact-registry-introduction-taipei
  44. 44. Q & A

×