Skip to content

Latest commit

 

History

History
55 lines (33 loc) · 2.27 KB

File metadata and controls

55 lines (33 loc) · 2.27 KB

Define And Deploy The App To Dev With CDK For Kubernetes (cdk8s)

Cloud Development Kit (CDK) for Kubernetes (cdk8s) is an open source software development framework for defining Kubernetes applications using familiar programming languages.

cdk8s reduces cognitive load for developers in three ways:

  • Developers can use the programming languages that they're already familiar with - and they can do all of the code things (conditionals, loops, inheritance, completion, testing, etc)
  • Developers interact with cdk8s' simplified API instead of the Kubernetes API - therefore they don't have to understand as much about Kubernetes
  • cdk8s can incorporate organization-wide guardrails and best practices so developers don't have to worry about it

cdk8s helps organizations in three ways:

  • cdk8s code synthesises into plain Kubernetes yaml manifests that can be applied to any distribution of Kubernetes
  • With cdk8s, you can define best practices and organization-wide defaults and distribute them as cdk8s libraries
  • Orgs can additionally incorporate policy enforcement in the synth step (when the cdk8s code gets reconciled into yaml)

The bottom line here is that organizations can give freedom to developers to write their own Kubernetes configuration in a pleasant and efficient way while also providing guardrails and best practices.

Setup

  • Install the cdk8s CLI
  • We'll define the manifests in Go (even though other languages are supported) so please install and configure Go.
chmod +x manuscript/define-deploy-dev/cdk8s.sh

./manuscript/define-deploy-dev/cdk8s.sh

Do

cd cdk8s

cat main.go

cat app.go

cdk8s synth --output ../yaml/dev --validate 

cd ..

cat yaml/dev/cncf-demo.k8s.yaml

kubectl --namespace dev apply --filename yaml/dev

echo "http://cncf-demo-dev.$DOMAIN"

# Open it in a browser
  • If you chose kbld to build images, you'll need to run the synth command to convert the chart into "pure" Kubernetes YAML manifests. Then with one command you can use kbld to build the images, push them to a registry, and modify the manifests with image SHAs. Next use kubectl to apply the manifests generated by kbld.

Continue The Adventure