How to get started, and achieve tasks, using Kubernetes

Edit This Page

Using kubectl to Manage Resources

This document is aimed at users who have worked through some of the examples, and who want to learn more about using kubectl to manage resources such as pods and services. Users who want to access the REST API directly, and developers who want to extend the Kubernetes API should refer to the api conventions and the api document.

Resources are Automatically Modified

When you create a resource such as pod, and then retrieve the created resource, a number of the fields of the resource are added. You can see this at work in the following example:

$ cat > /tmp/original.yaml <<EOF
apiVersion: v1
kind: Pod
  name: foo
    - name: foo
      image: busybox
  restartPolicy: Never
$ kubectl create -f /tmp/original.yaml
$ kubectl get pods/foo -o yaml > /tmp/current.yaml
$ wc -l /tmp/original.yaml /tmp/current.yaml
      51 /tmp/current.yaml
       9 /tmp/original.yaml
      60 total

The resource we posted had only 9 lines, but the one we got back had 51 lines. If you diff -u /tmp/original.yaml /tmp/current.yaml, you can see the fields added to the pod. The system adds fields in several ways:

The API will generally not modify fields that you have set; it just sets ones which were unspecified.

Finding Documentation on Resource Fields

You can browse auto-generated API documentation here.


Create Issue Edit This Page