Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Templating and Rendering Using Kustomization an...

Avatar for Irvi Aini Irvi Aini
November 27, 2021

Templating and Rendering Using Kustomization and Kpt

Avatar for Irvi Aini

Irvi Aini

November 27, 2021
Tweet

More Decks by Irvi Aini

Other Decks in Programming

Transcript

  1. “kustomize lets you customize raw, template-free YAML files for multiple

    purposes, leaving the original YAML untouched and usable as is.” This tools is originally sponsored by sig-cli as mentioned in the KEP. TL;DR • Helps customizing config files in a template free way. • Provides a number of handy methods like generators to make customization easier, e.g ConfigMap and Secret • Provides patches to introduce environment specific changes on an already existing standard config file without disturbing the original files Kustomize
  2. • Create a Kustomization file, this configuration should declare all

    of the resources that you’d like to apply the configuration over them • Create variants using overlays, generally speaking an overlay is just another Kustomization file which will be referring to base configuration and additional patches that you’d like to apply for each of the environments Kustomize Usage
  3. resources - what existing resources are to be customized. Example

    fields: resources, crds. meta - fields which may influence all or some of the above. Example fields: vars, namespace, apiVersion, kind, etc generators - what new resources should be created. Example fields: configMapGenerator (legacy), secretGenerator (legacy), generators (v2.1). transformers: alter specific bits of your resource definitions. e.g. labels, annotations
  4. For further discussion we will use kpt v1. In general,

    the 2 fundamentals concept in kpt are: • Packages. A package is a bundle of configuration data, which is explicitly declare inside of Kptfile. Note that a package can be a part of another package, called as a subpackage. • Functions. A containerized program that can perform CRUD operations on Kubernetes Resource Model (KRM) resources stored on your local, it also act as a mechanism to automate mutation and validation of KRM resources. Kpt Concepts
  5. Contains the user-specified Git reference to the upstream package Records

    the upstream Git reference (exact Git SHA) that was fetched by kpt. This section is managed and should not be changed manually. Modified from: Getting a Package
  6. Skaffold’s Architecture Skaffold handles the workflow for building, pushing, and

    deploying your application, and provides building blocks for creating CI/CD pipelines.
  7. Version of the configuration Project’s identifier Determines how images are

    tagged. Images that needs to be build, in this case the image is build using jib. Describes how the images are deployed Override for multiple environments. More references can be seen in this page.
  8. jib configuration to build the container kustomize overlays Kptfile Skaffold

    Sample code is available on irvifa/skaffold-kpt-example
  9. jib configuration to build the container kustomize overlays Kptfile Skaffold

    Sample code is available on irvifa/skaffold-kpt-example Where is the Dockerfile??
  10. Sample code is available on irvifa/skaffold-kpt-example jib configuration to build

    the container kustomize overlays Kptfile Skaffold Where is the Dockerfile?? Skaffold ♡ Jib
  11. Builder: Jib is a set of plugins used or building

    optimized OCI-compliant container images for Java applications without a Docker daemon. Tagger: inputDigest: if there’s no changes inside the source files then the tag won’t be changed.
  12. With Jib With Docker Why Jib? 🤔 Jib is already

    an official builder for Skaffold I’m using Java and since Jib is available I don’t want to care about my Dockerfiles
  13. Base image Application main class will act as entry point.

    Ports where the server will be served.
  14. Port Forwarding Built-in support for forwarding ports from exposed Kubernetes

    resources to your local machine when running in dev, debug, deploy, or run modes.
  15. Skaffold dev loop File sync Build Test Deploy If there’s

    changes on your source code then it will be deployed