Skip to content

Insert yaml fragment #781

Closed Answered by Peefy
willzhang asked this question in Q&A
Discussion options

You must be logged in to vote

If you only want to use KCL code and YAML files, this is also possible. I will write the following example to illustrate:

The kcl code (main.k)

import yaml

yaml.decode(option("source", default="{}")) | {
    # Use the `+=` to patch the cni-plugin sidecar container config
    spec.containers += [
        {
            image: "docker.io/labring4docker/cni-plugins:v1.3.0"
            name: "install-cni-plugins"
            command: ["/bin/sh"]
            args: ["-c", "cp -au /cni-plugins/* /cni-plugin/"]
        }
    ]
}

The source yaml (source.yaml)

apiVersion: v1
kind: Pod
metadata:
  annotations:
    inject-certs: enabled
  name: nginx
spec:
  containers:
  - image: nginx:1.14.2
    name

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by willzhang
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants