Skip to content

IMT-Atlantique-FIL-2020-2023/dtree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DTree

Materials

Commands

> dtree make -h
Generate the dependancy tree for the given .yaml config and .json struct

Usage:
  dtree make [flags]

Flags:
  -c, --config string     The yaml config file (default "./config.yaml")
  -f, --format string     The format of the output (config, template or tree) (default "tree")
  -h, --help              help for make
  -t, --template string   The template definition file (default "./template.json")

Example

go run main.go make -c ./assets/config.yaml -t ./assets/template.json

Reference template: template.json Reference config: config.yaml

Example queried config:

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mypod
    image: redis
    volumeMounts:
    - name: foo
      mountPath: "/etc/foo"
      readOnly: true
  volumes:
  - name: foo
    secret:
      secretName: mysecret
      optional: false

Step 1: Pod

Found template from kind: io.k8s.api.core.v1.Pod

Required field in template: None

Existing references in template:

  1. metadata: "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
  2. spec: "#/definitions/io.k8s.api.core.v1.PodSpec",
  3. status: "#/definitions/io.k8s.api.core.v1.PodStatus",

Found in Config: 1. and 2.

Step 2: Pod / ObjectMeta

Referenced template: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta

Required field in template: None

Existing references in template:

  1. creationTimestamp: "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time",
  2. deletionTimestamp: "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time",
  3. managedFields: "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry",
  4. ownerReferences: "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference"

Found in Config: None

Step 3: Pod / PodSpec

Referenced template: io.k8s.api.core.v1.PodSpec

Required field in template: "containers"

Existing references in template:

  1. volumes > items: "#/definitions/io.k8s.api.core.v1.Volume"
  2. containers > items: "#/definitions/io.k8s.api.core.v1.Container"
  3. ...

Found in Config: 1. and 2.

Step 4: Pod / PodSpec / Volume

Referenced template: io.k8s.api.core.v1.Volume

Required field in template: "name"

Existing references in template:

  1. secret: io.k8s.api.core.v1.SecretVolumeSource
  2. ...

Found in Config: 1.

Step 5: Pod / PodSpec / Volume / SecretVolumeSource

Referenced template: io.k8s.api.core.v1.SecretVolumeSource

Required field in template: None

Existing references in template:

  1. ...

Found in Config: None

Step 6: Pod / PodSpec / Container

Referenced template: io.k8s.api.core.v1.Container

Required field in template: "name"

Existing references in template:

  1. volumeMounts > items: io.k8s.api.core.v1.VolumeMount
  2. ...

Found in Config: 1.

Step 7: Pod / PodSpec / Container / VolumeMount

Referenced template: io.k8s.api.core.v1.VolumeMount

Required field in template: "name", "mountPath"

Existing references in template:

  1. ...

Found in Config: None

STOP

Outputs

Template: dtree make -f "template"

Required fields for the given configuration: 
 * io.k8s.api.core.v1.PodSpec.properties.containers   
 * io.k8s.api.core.v1.Container.properties.name       
 * io.k8s.api.core.v1.VolumeMount.properties.name     
 * io.k8s.api.core.v1.VolumeMount.properties.mountPath
 * io.k8s.api.core.v1.Volume.properties.name

Config: dtree make -f "config"

Required fields for the given configuration: 
 * .spec.containers = map[items:[map[image:redis name:mypod volumeMounts:map[items:[map[mountPath:/etc/foo name:foo readOnly:true]]]]]]
 * .spec.volumes.name = foo
 * .spec.containers.name = mypod
 * .spec.containers.volumeMounts.name = foo
 * .spec.containers.volumeMounts.mountPath = /etc/foo

Tree: dtree make -f "tree"

Required fields for the given configuration:
{
  "spec": {
    "containers": {
      "name": "mypod",
      "volumeMounts": {
        "mountPath": "/etc/foo",
        "name": "foo"
      }
    },
    "volumes": {
      "name": "foo"
    }
  }
}

About

k8s config dependencies tool checker

Topics

Resources

License

Stars

Watchers

Forks

Languages