Skip to content
Terskikh Maria edited this page Jan 12, 2018 · 7 revisions

The chkit create command creates one of 2 types of objects:

  • Deployment
  • Service

from JSON file. You can create JSON file using the example below.

Command syntax

chkit create has to be executed with one mandatory parameter:

Flag Parameter Description
--file или -f FILE JSON file name

Optional parameters:

Flag Parameter Description
--help or -h print usage info
--debug or -d print system info on command execution
$ chkit [--debug -d ] create (-f FILE | --file FILE)[--help | -h]

Example

$ chkit create -f MyDeploy.json

create... OK

To create for example nginx Deployment you can use this template:

Note: in this template "default-volume" is the name of Volume. To get list of all your Volumes use chkit volume command and use this template with the name of one of your own Volume.

{
    "kind": "Deployment",
    "metadata": {
        "labels": {},
        "name": "nginx"
    },
    "spec": {
        "replicas": 2,
        "template": {
            "metadata": {
                "labels": {},
                "name": "nginx"
            },
            "spec": {
                "containers": [
                    {
                        "command": [
                            "ls"
                        ],
                        "env": [
                            {
                                "name": "PORT",
                                "value": "80"
                            },
                            {
                                "name": "IP",
                                "value": "0.0.0.0"
                            },
                            {
                                "name": "testenv",
                                "value": "testval"
                            }
                        ],
                        "image": "nginx",
                        "name": "nginx",
                        "ports": [
                            {
                                "containerPort": 80
                            },
                            {
                                "containerPort": 443
                            }
                        ],
                        "resources": {
                            "requests": {
                                "cpu": "200m",
                                "memory": "256Mi"
                            }
                        },
                        "volumeMounts": [
                            {
                                "name": "default-volume",
                                "mountPath": "/var/lib/nginx",
                                "subPath": "nginx/data"
                            }
                        ]
                    }
                ],
                "volumes": [
                    {
                        "name": "default-volume"
                    }
                ]
            }
        }
    }
}	

To create Service for nginx you can use this template:

{
    "kind": "Service",
    "metadata": {
        "labels": {
            "37a8eec1ce19687d132fe29051dca629": "nginx",
            "external": "true"
        },
        "name": "nginx-3198"
    },
    "spec": {
        "ports": [
            {
                "targetPort": 80,
                "name": "http",
                "protocol": "TCP"
            },
            {
                "targetPort": 443,
                "name": "https",
                "protocol": "TCP"
            }
        ],
        "selector": {
            "37a8eec1ce19687d132fe29051dca629": "nginx"
        }
    }
}

JSON Specification

For Deployment:

.kind  - kind of object ("Deployment")
.metadata - metainfo
  .labels - labels
  .name - name of object
.spec - specification
  .replicas - quantity of replicas
  .template - template for pods
    .metadata - metainfo for pods
      .labels - labels for pods
      .name - name of pod
    .spec - specification for pods
      .containers - containers list
      [
        .command - commands for deployment
        .env - environment variables
          .name - name of environment variable
          .value - value of environment variable
        .image - image of deployment for container
        .name - name of container
        .ports - ports
        [
          .containers - container's port
        ]
        .resources - resources for the container
          .requests - resources for the pod
            .cpu - CPU
            .memory - RAM
        .volumeMounts - external volumes for the container
        [
          .name - name of volume
          .mountPath - path for the volume in the container
          .subPath - path in the volume
        ]
      ]
      .volume - list of volume
      [
        .name - name of volume
      ]

For Service:

.kind  - kind of object ("Service")
.metadata - metainfo
  .labels - labels
  .name - name
.spec - specification
    .ports - ports
    [
        .targetPort - port in the container 
        .name - name of port
        .protocol - protocol
        .port - internal port
    ]
    .selector - selector of deployment by label