Example of a pod configuration

Example of a pod configuration

You need to define a pod for each virtual machine that you want to place under Kubernetes orchestration.

Pods are defined as .yaml files. The following text is an example of a pod configuration for a VM with Virtlet:

apiVersion: v1
kind: Pod
metadata:
  name: cirros-vm
  annotations:
    kubernetes.io/target-runtime: virtlet
    VirtletVCPUCount: "1"
    VirtletSSHKeys: |
      ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaJEcFDXEK2Zb
      X0ZLS1EIYFZRbDAcRfuVjpstSc0De8+sV1aiu+dePxdkuDRwqFt
      Cyk6dEZkssjOkBXtri00MECLkir6FcH3kKOJtbJ6vy3uaJc9w1E
      Ro+wyl6SkAh/+JTJkp7QRXj8oylW5E20LsbnA/dIwWzAF51PPwF
      7A7FtNg9DnwPqMkxFo1Th/buOMKbP5ZA1mmNNtmzbMpMfJATvVy
      iv3ccsSJKOiyQr6UG+j7sc/7jMVz5Xk34Vd0l8GwcB0334MchHc
      kmqDB142h/NCWTr8oLakDNvkfC1YneAfAO41hDkUbxPtVBG5M/o
      7P4fxoqiHEX+ZLfRxDtHB53 me@localhost
    VirtletCloudInitUserDataScript: |
      #!/bin/sh
      echo "Hi there"
spec:
 affinity:
   nodeAffinity:
     requiredDuringSchedulingIgnoredDuringExecution:
       nodeSelectorTerms:
       - matchExpressions:
         - key: extraRuntime
           operator: In
           values:
           - virtlet
containers:
- name: cirros-vm
  image: virtlet/download.cirros-cloud.net/0.3.5/
  cirros-0.3.5-x86_64-disk.img
  resources:
    limits:
      memory: 128Mi

The following table describes the pod configuration parameters:

Pod definition paramaters

Parameter

Description

apiVersion

Version of the Kubernetes API.

kind

Type of the file. For all pod configurations, the kind parameter value is Pod.

metadata

Specifies a number of parameters required for the pod configuration, including:

  • name - the name of the pod.

  • annotations - a subset of metadata parameters in the form of strings. Numeric values must be quoted:

    • kubernetes.io/target-runtime - defines that this pod belongs to the Virtlet runtime.

    • VirtletVCPUCount - (optional) specifies the number of virtual CPUs. The default value is 1.

    • VirtletSSHKeys - one or many SSH keys, one key per line.

    • VirtletCloudInitUserDataScript - user data for the cloud-init script.

spec

Pod specification, including:

  • nodeAffinity - the specification in the example above ensures that Kubernetes runs this pod only on the nodes that have the extraRuntime=virtlet label. This label is used by the Virtlet DaemonSet to select nodes that must have the Virtlet runtime.

  • containers - a container configuration that includes:

    • name - name of the container.

    • image - specifies the path to a network location where the Docker image is stored. The path must start with the virtlet prefix followed by the URL to the required location.

    • resources - defines the resources, such as memory limitation for the libvirt domain.