Prompt:
Complete this text code:

The following kubectl-compatible plugins are available:

/usr/local/bin/kubectl-hello
/usr/local/bin/kubectl-foo

Response:
  - warning: /usr/local/bin/kubectl-foo identified as a plugin, but it is not executable
/usr/local/bin/kubectl-bar

error: one plugin warning was found


Prompt:
Explain this text code:

The following kubectl-compatible plugins are available:

/usr/local/bin/kubectl-hello
/usr/local/bin/kubectl-foo
  - warning: /usr/local/bin/kubectl-foo identified as a plugin, but it is not executable
/usr/local/bin/kubectl-bar

error: one plugin warning was found

Response: This text code Command line tool (kubectl) | You can think of plugins as a means to build more complex functionality on top of the existing kubectl commands:

Context: Command line tool (kubectl) | You can think of plugins as a means to build more complex functionality on top of the existing kubectl commands:


Prompt:
Complete this text code:

#!/bin/bash

Response:
# this plugin makes use of the `kubectl config` command in order to output
# information about the current user, based on the currently selected context
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'

Context: Command line tool (kubectl) | Running the above command gives you an output containing the user for the current context in your KUBECONFIG file:


Prompt:
Explain this text code:

#!/bin/bash

# this plugin makes use of the `kubectl config` command in order to output
# information about the current user, based on the currently selected context
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'

Response: This text code Command line tool (kubectl) | Running the above command gives you an output containing the user for the current context in your KUBECONFIG file:


Prompt:
Complete this text code:

# make the file executable
sudo chmod +x ./kubectl-whoami

# and move it into your PATH

Response:
sudo mv ./kubectl-whoami /usr/local/bin

kubectl whoami
Current user: plugins-user

Context: Command line tool (kubectl) |


Prompt:
Explain this text code:

# make the file executable
sudo chmod +x ./kubectl-whoami

# and move it into your PATH
sudo mv ./kubectl-whoami /usr/local/bin

kubectl whoami
Current user: plugins-user

Response: This text code Command line tool (kubectl) |

Context: Command line tool (kubectl) |


Prompt:
Explain this shell code:

kubectl get pod pod1
kubectl get pods pod1
kubectl get po pod1

Response: This shell code Command line tool (kubectl) | NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example kubectl get pods.

Context: Command line tool (kubectl) | NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example kubectl get pods.


Prompt:
Explain this text code:

TYPE1/name1 TYPE1/name2 TYPE2/name3 TYPE<#>/name<#>

Response: This text code Command line tool (kubectl) | To specify resources with one or more files: -f file1 -f file2 -f file<#>

Context: Command line tool (kubectl) | To specify resources with one or more files: -f file1 -f file2 -f file<#>


Prompt:
Explain this bash code:

kubectl get pod/example-pod1 replicationcontroller/example-rc1

Response: This bash code Command line tool (kubectl) | To specify resources with one or more files: -f file1 -f file2 -f file<#>


Prompt:
Explain this text code:

/var/run/secrets/kubernetes.io/serviceaccount/token

Response: This text code Command line tool (kubectl) | To maintain backwards compatibility, if the POD_NAMESPACE environment variable is set during in-cluster authentication it will override the default namespace from the service account token. Any manife

Context: Command line tool (kubectl) | To maintain backwards compatibility, if the POD_NAMESPACE environment variable is set during in-cluster authentication it will override the default namespace from the service account token. Any manife


Prompt:
Explain this text code:

/var/run/secrets/kubernetes.io/serviceaccount/token

Response: This text code Command line tool (kubectl) | then kubectl assumes it is running in your cluster. The kubectl tool looks up the namespace of that ServiceAccount (this is the same as the namespace of the Pod) and acts against that namespace. This

Context: Command line tool (kubectl) | then kubectl assumes it is running in your cluster. The kubectl tool looks up the namespace of that ServiceAccount (this is the same as the namespace of the Pod) and acts against that namespace. This


Prompt:
Explain this shell code:

kubectl config set-context --current --namespace=<namespace-name>

Response: This shell code Command line tool (kubectl) | The following table includes short descriptions and the general syntax for all of the kubectl operations:

Context: Command line tool (kubectl) | The following table includes short descriptions and the general syntax for all of the kubectl operations:


Prompt:
Explain this bash code:

kubectl annotate (-f FILENAME | TYPE NAME | TYPE/NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--overwrite] [--all] [--resource-version=version] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.

Context: Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl cp <file-spec-src> <file-spec-dest> [options]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl delete (-f FILENAME | TYPE [NAME | /NAME | -l label | --all]) [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl describe (-f FILENAME | TYPE [NAME_PREFIX | /NAME | -l label]) [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl edit (-f FILENAME | TYPE NAME | TYPE/NAME) [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl exec POD [-c CONTAINER] [-i] [-t] [flags] [-- COMMAND [args...]]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl expose (-f FILENAME | TYPE NAME | TYPE/NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl get (-f FILENAME | TYPE [NAME | /NAME | -l label]) [--watch] [--sort-by=FIELD] [[-o | --output]=OUTPUT_FORMAT] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl label (-f FILENAME | TYPE NAME | TYPE/NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--overwrite] [--all] [--resource-version=version] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl patch (-f FILENAME | TYPE NAME | TYPE/NAME) --patch PATCH [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl port-forward POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client|none] [--overrides=inline-json] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl scale (-f FILENAME | TYPE NAME | TYPE/NAME) --replicas=COUNT [--resource-version=version] [--current-replicas=count] [flags]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N [options]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this bash code:

kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l label | --all)]) [--for=delete|--for condition=available] [options]

Response: This bash code Command line tool (kubectl) | To learn more about command operations, see the kubectl reference documentation.


Prompt:
Explain this shell code:

kubectl get pods <pod-name> -o custom-columns=NAME:.metadata.name,RSRC:.metadata.resourceVersion

Response: This shell code Command line tool (kubectl) | Template file:

Context: Command line tool (kubectl) | Template file:


Prompt:
Explain this shell code:

kubectl get pods <pod-name> -o custom-columns-file=template.txt

Response: This shell code Command line tool (kubectl) | where the template.txt file contains:

Context: Command line tool (kubectl) | where the template.txt file contains:


Prompt:
Explain this text code:

NAME          RSRC
metadata.name metadata.resourceVersion

Response: This text code Command line tool (kubectl) | The result of running either command is similar to:

Context: Command line tool (kubectl) | The result of running either command is similar to:


Prompt:
Explain this shell code:

kubectl [command] [TYPE] [NAME] --sort-by=<jsonpath_exp>

Response: This shell code Command line tool (kubectl) | To print a list of pods sorted by name, you run:

Context: Command line tool (kubectl) | To print a list of pods sorted by name, you run:


Prompt:
Complete this shell code:

# Create a service using the definition in example-service.yaml.
kubectl apply -f example-service.yaml

# Create a replication controller using the definition in example-controller.yaml.

Response:
kubectl apply -f example-controller.yaml

# Create the objects that are defined in any .yaml, .yml, or .json file within the <directory> directory.
kubectl apply -f <directory>

Context: Command line tool (kubectl) | kubectl get - List one or more resources.


Prompt:
Explain this shell code:

# Create a service using the definition in example-service.yaml.
kubectl apply -f example-service.yaml

# Create a replication controller using the definition in example-controller.yaml.
kubectl apply -f example-controller.yaml

# Create the objects that are defined in any .yaml, .yml, or .json file within the <directory> directory.
kubectl apply -f <directory>

Response: This shell code Command line tool (kubectl) | kubectl get - List one or more resources.


Prompt:
Complete this shell code:

# List all pods in plain-text output format.
kubectl get pods

# List all pods in plain-text output format and include additional information (such as node name).
kubectl get pods -o wide

# List the replication controller with the specified name in plain-text output format. Tip: You can shorten and replace the 'replicationcontroller' resource type with the alias 'rc'.
kubectl get replicationcontroller <rc-name>

Response:
# List all replication controllers and services together in plain-text output format.
kubectl get rc,services

# List all daemon sets in plain-text output format.
kubectl get ds

# List all pods running on node server01
kubectl get pods --field-selector=spec.nodeName=server01

Context: Command line tool (kubectl) | kubectl describe - Display detailed state of one or more resources, including the uninitialized ones by default.


Prompt:
Explain this shell code:

# List all pods in plain-text output format.
kubectl get pods

# List all pods in plain-text output format and include additional information (such as node name).
kubectl get pods -o wide

# List the replication controller with the specified name in plain-text output format. Tip: You can shorten and replace the 'replicationcontroller' resource type with the alias 'rc'.
kubectl get replicationcontroller <rc-name>

# List all replication controllers and services together in plain-text output format.
kubectl get rc,services

# List all daemon sets in plain-text output format.
kubectl get ds

# List all pods running on node server01
kubectl get pods --field-selector=spec.nodeName=server01

Response: This shell code Command line tool (kubectl) | kubectl describe - Display detailed state of one or more resources, including the uninitialized ones by default.


Prompt:
Complete this shell code:

# Display the details of the node with name <node-name>.
kubectl describe nodes <node-name>

# Display the details of the pod with name <pod-name>.
kubectl describe pods/<pod-name>

Response:
# Display the details of all the pods that are managed by the replication controller named <rc-name>.
# Remember: Any pods that are created by the replication controller get prefixed with the name of the replication controller.
kubectl describe pods <rc-name>

# Describe all pods
kubectl describe pods

Context: Command line tool (kubectl) | kubectl delete - Delete resources either from a file, stdin, or specifying label selectors, names, resource selectors, or resources.


Prompt:
Explain this shell code:

# Display the details of the node with name <node-name>.
kubectl describe nodes <node-name>

# Display the details of the pod with name <pod-name>.
kubectl describe pods/<pod-name>

# Display the details of all the pods that are managed by the replication controller named <rc-name>.
# Remember: Any pods that are created by the replication controller get prefixed with the name of the replication controller.
kubectl describe pods <rc-name>

# Describe all pods
kubectl describe pods

Response: This shell code Command line tool (kubectl) | kubectl delete - Delete resources either from a file, stdin, or specifying label selectors, names, resource selectors, or resources.


Prompt:
Complete this shell code:

# Delete a pod using the type and name specified in the pod.yaml file.
kubectl delete -f pod.yaml

# Delete all the pods and services that have the label '<label-key>=<label-value>'.

Response:
kubectl delete pods,services -l <label-key>=<label-value>

# Delete all pods, including uninitialized ones.
kubectl delete pods --all

Context: Command line tool (kubectl) | kubectl exec - Execute a command against a container in a pod.


Prompt:
Explain this shell code:

# Delete a pod using the type and name specified in the pod.yaml file.
kubectl delete -f pod.yaml

# Delete all the pods and services that have the label '<label-key>=<label-value>'.
kubectl delete pods,services -l <label-key>=<label-value>

# Delete all pods, including uninitialized ones.
kubectl delete pods --all

Response: This shell code Command line tool (kubectl) | kubectl exec - Execute a command against a container in a pod.


Prompt:
Complete this shell code:

# Get output from running 'date' from pod <pod-name>. By default, output is from the first container.
kubectl exec <pod-name> -- date

# Get output from running 'date' in container <container-name> of pod <pod-name>.

Response:
kubectl exec <pod-name> -c <container-name> -- date

# Get an interactive TTY and run /bin/bash from pod <pod-name>. By default, output is from the first container.
kubectl exec -ti <pod-name> -- /bin/bash

Context: Command line tool (kubectl) | kubectl logs - Print the logs for a container in a pod.


Prompt:
Explain this shell code:

# Get output from running 'date' from pod <pod-name>. By default, output is from the first container.
kubectl exec <pod-name> -- date

# Get output from running 'date' in container <container-name> of pod <pod-name>.
kubectl exec <pod-name> -c <container-name> -- date

# Get an interactive TTY and run /bin/bash from pod <pod-name>. By default, output is from the first container.
kubectl exec -ti <pod-name> -- /bin/bash

Response: This shell code Command line tool (kubectl) | kubectl logs - Print the logs for a container in a pod.


Prompt:
Complete this shell code:

# Return a snapshot of the logs from pod <pod-name>.
kubectl logs <pod-name>

Response:
# Start streaming the logs from pod <pod-name>. This is similar to the 'tail -f' Linux command.
kubectl logs -f <pod-name>

Context: Command line tool (kubectl) | kubectl diff - View a diff of the proposed updates to a cluster.


Prompt:
Explain this shell code:

# Return a snapshot of the logs from pod <pod-name>.
kubectl logs <pod-name>

# Start streaming the logs from pod <pod-name>. This is similar to the 'tail -f' Linux command.
kubectl logs -f <pod-name>

Response: This shell code Command line tool (kubectl) | kubectl diff - View a diff of the proposed updates to a cluster.


Prompt:
Complete this shell code:

# Diff resources included in "pod.json".
kubectl diff -f pod.json

Response:
# Diff file read from stdin.
cat service.yaml | kubectl diff -f -

Context: Command line tool (kubectl) | Use the following set of examples to help you familiarize yourself with writing and using kubectl plugins:


Prompt:
Explain this shell code:

# Diff resources included in "pod.json".
kubectl diff -f pod.json

# Diff file read from stdin.
cat service.yaml | kubectl diff -f -

Response: This shell code Command line tool (kubectl) | Use the following set of examples to help you familiarize yourself with writing and using kubectl plugins:


Prompt:
Explain this shell code:

# create a simple plugin in any language and name the resulting executable file
# so that it begins with the prefix "kubectl-"
cat ./kubectl-hello

Response: This shell code Command line tool (kubectl) | With a plugin written, let's make it executable:

Context: Command line tool (kubectl) | With a plugin written, let's make it executable:


Prompt:
Complete this shell code:

#!/bin/sh

Response:
# this plugin prints the words "hello world"
echo "hello world"


Prompt:
Explain this shell code:

#!/bin/sh

# this plugin prints the words "hello world"
echo "hello world"

Response: This shell code Command line tool (kubectl) | With a plugin written, let's make it executable:


Prompt:
Complete this bash code:

chmod a+x ./kubectl-hello

# and move it to a location in our PATH
sudo mv ./kubectl-hello /usr/local/bin

Response:
sudo chown root:root /usr/local/bin

# You have now created and "installed" a kubectl plugin.
# You can begin using this plugin by invoking it from kubectl as if it were a regular command
kubectl hello

Context: Command line tool (kubectl) | In order to view all of the plugins that are available to kubectl, use the kubectl plugin list subcommand:


Prompt:
Explain this bash code:

chmod a+x ./kubectl-hello

# and move it to a location in our PATH
sudo mv ./kubectl-hello /usr/local/bin
sudo chown root:root /usr/local/bin

# You have now created and "installed" a kubectl plugin.
# You can begin using this plugin by invoking it from kubectl as if it were a regular command
kubectl hello

Response: This bash code Command line tool (kubectl) | In order to view all of the plugins that are available to kubectl, use the kubectl plugin list subcommand:


Prompt:
Explain this shell code:

# You can "uninstall" a plugin, by removing it from the folder in your
# $PATH where you placed it
sudo rm /usr/local/bin/kubectl-hello

Response: This shell code Command line tool (kubectl) | In order to view all of the plugins that are available to kubectl, use the kubectl plugin list subcommand:


Prompt:
Complete this text code:

The following kubectl-compatible plugins are available:

Response:
/usr/local/bin/kubectl-hello
/usr/local/bin/kubectl-foo
/usr/local/bin/kubectl-bar

Context: Command line tool (kubectl) | kubectl plugin list also warns you about plugins that are not executable, or that are shadowed by other plugins; for example:


Prompt:
Explain this text code:

The following kubectl-compatible plugins are available:

/usr/local/bin/kubectl-hello
/usr/local/bin/kubectl-foo
/usr/local/bin/kubectl-bar

Response: This text code Command line tool (kubectl) | kubectl plugin list also warns you about plugins that are not executable, or that are shadowed by other plugins; for example:


Prompt:
Explain this shell code:

sudo chmod -x /usr/local/bin/kubectl-foo # remove execute permission
kubectl plugin list

Response: This shell code Command line tool (kubectl) | You can think of plugins as a means to build more complex functionality on top of the existing kubectl commands:

Context: Command line tool (kubectl) | You can think of plugins as a means to build more complex functionality on top of the existing kubectl commands:


Prompt:
Complete this text code:

The following kubectl-compatible plugins are available:

/usr/local/bin/kubectl-hello
/usr/local/bin/kubectl-foo

Response:
  - warning: /usr/local/bin/kubectl-foo identified as a plugin, but it is not executable
/usr/local/bin/kubectl-bar

error: one plugin warning was found


Prompt:
Explain this text code:

The following kubectl-compatible plugins are available:

/usr/local/bin/kubectl-hello
/usr/local/bin/kubectl-foo
  - warning: /usr/local/bin/kubectl-foo identified as a plugin, but it is not executable
/usr/local/bin/kubectl-bar

error: one plugin warning was found

Response: This text code Command line tool (kubectl) | You can think of plugins as a means to build more complex functionality on top of the existing kubectl commands:


Prompt:
Complete this shell code:

#!/bin/bash

Response:
# this plugin makes use of the `kubectl config` command in order to output
# information about the current user, based on the currently selected context
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'

Context: Command line tool (kubectl) | Running the above command gives you an output containing the user for the current context in your KUBECONFIG file:


Prompt:
Explain this shell code:

#!/bin/bash

# this plugin makes use of the `kubectl config` command in order to output
# information about the current user, based on the currently selected context
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'

Response: This shell code Command line tool (kubectl) | Running the above command gives you an output containing the user for the current context in your KUBECONFIG file:


Prompt:
Complete this shell code:

# make the file executable
sudo chmod +x ./kubectl-whoami

# and move it into your PATH

Response:
sudo mv ./kubectl-whoami /usr/local/bin

kubectl whoami
Current user: plugins-user

Context: Command line tool (kubectl) |


Prompt:
Explain this shell code:

# make the file executable
sudo chmod +x ./kubectl-whoami

# and move it into your PATH
sudo mv ./kubectl-whoami /usr/local/bin

kubectl whoami
Current user: plugins-user

Response: This shell code Command line tool (kubectl) |

Context: Command line tool (kubectl) |


Prompt:
Explain this bash code:

kubectl get pod pod1
kubectl get pods pod1
kubectl get po pod1

Response: This bash code Command line tool (kubectl) | NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example kubectl get pods.

Context: Command line tool (kubectl) | NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example kubectl get pods.


Prompt:
Explain this bash code:

kubectl config set-context --current --namespace=<namespace-name>

Response: This bash code Command line tool (kubectl) | The following table includes short descriptions and the general syntax for all of the kubectl operations:

Context: Command line tool (kubectl) | The following table includes short descriptions and the general syntax for all of the kubectl operations:


Prompt:
Explain this bash code:

kubectl get pods <pod-name> -o custom-columns=NAME:.metadata.name,RSRC:.metadata.resourceVersion

Response: This bash code Command line tool (kubectl) | Template file:

Context: Command line tool (kubectl) | Template file:


Prompt:
Explain this bash code:

kubectl get pods <pod-name> -o custom-columns-file=template.txt

Response: This bash code Command line tool (kubectl) | where the template.txt file contains:

Context: Command line tool (kubectl) | where the template.txt file contains:


Prompt:
Explain this bash code:

kubectl [command] [TYPE] [NAME] --sort-by=<jsonpath_exp>

Response: This bash code Command line tool (kubectl) | To print a list of pods sorted by name, you run:

Context: Command line tool (kubectl) | To print a list of pods sorted by name, you run:


Prompt:
Complete this text code:

# Create a service using the definition in example-service.yaml.
kubectl apply -f example-service.yaml

# Create a replication controller using the definition in example-controller.yaml.

Response:
kubectl apply -f example-controller.yaml

# Create the objects that are defined in any .yaml, .yml, or .json file within the <directory> directory.
kubectl apply -f <directory>

Context: Command line tool (kubectl) | kubectl get - List one or more resources.


Prompt:
Explain this text code:

# Create a service using the definition in example-service.yaml.
kubectl apply -f example-service.yaml

# Create a replication controller using the definition in example-controller.yaml.
kubectl apply -f example-controller.yaml

# Create the objects that are defined in any .yaml, .yml, or .json file within the <directory> directory.
kubectl apply -f <directory>

Response: This text code Command line tool (kubectl) | kubectl get - List one or more resources.


Prompt:
Complete this text code:

# List all pods in plain-text output format.
kubectl get pods

# List all pods in plain-text output format and include additional information (such as node name).
kubectl get pods -o wide

# List the replication controller with the specified name in plain-text output format. Tip: You can shorten and replace the 'replicationcontroller' resource type with the alias 'rc'.
kubectl get replicationcontroller <rc-name>

Response:
# List all replication controllers and services together in plain-text output format.
kubectl get rc,services

# List all daemon sets in plain-text output format.
kubectl get ds

# List all pods running on node server01
kubectl get pods --field-selector=spec.nodeName=server01

Context: Command line tool (kubectl) | kubectl describe - Display detailed state of one or more resources, including the uninitialized ones by default.


Prompt:
Explain this text code:

# List all pods in plain-text output format.
kubectl get pods

# List all pods in plain-text output format and include additional information (such as node name).
kubectl get pods -o wide

# List the replication controller with the specified name in plain-text output format. Tip: You can shorten and replace the 'replicationcontroller' resource type with the alias 'rc'.
kubectl get replicationcontroller <rc-name>

# List all replication controllers and services together in plain-text output format.
kubectl get rc,services

# List all daemon sets in plain-text output format.
kubectl get ds

# List all pods running on node server01
kubectl get pods --field-selector=spec.nodeName=server01

Response: This text code Command line tool (kubectl) | kubectl describe - Display detailed state of one or more resources, including the uninitialized ones by default.


Prompt:
Complete this text code:

# Display the details of the node with name <node-name>.
kubectl describe nodes <node-name>

# Display the details of the pod with name <pod-name>.
kubectl describe pods/<pod-name>

Response:
# Display the details of all the pods that are managed by the replication controller named <rc-name>.
# Remember: Any pods that are created by the replication controller get prefixed with the name of the replication controller.
kubectl describe pods <rc-name>

# Describe all pods
kubectl describe pods

Context: Command line tool (kubectl) | kubectl delete - Delete resources either from a file, stdin, or specifying label selectors, names, resource selectors, or resources.


Prompt:
Explain this text code:

# Display the details of the node with name <node-name>.
kubectl describe nodes <node-name>

# Display the details of the pod with name <pod-name>.
kubectl describe pods/<pod-name>

# Display the details of all the pods that are managed by the replication controller named <rc-name>.
# Remember: Any pods that are created by the replication controller get prefixed with the name of the replication controller.
kubectl describe pods <rc-name>

# Describe all pods
kubectl describe pods

Response: This text code Command line tool (kubectl) | kubectl delete - Delete resources either from a file, stdin, or specifying label selectors, names, resource selectors, or resources.


Prompt:
Complete this text code:

# Delete a pod using the type and name specified in the pod.yaml file.
kubectl delete -f pod.yaml

# Delete all the pods and services that have the label '<label-key>=<label-value>'.

Response:
kubectl delete pods,services -l <label-key>=<label-value>

# Delete all pods, including uninitialized ones.
kubectl delete pods --all

Context: Command line tool (kubectl) | kubectl exec - Execute a command against a container in a pod.


Prompt:
Explain this text code:

# Delete a pod using the type and name specified in the pod.yaml file.
kubectl delete -f pod.yaml

# Delete all the pods and services that have the label '<label-key>=<label-value>'.
kubectl delete pods,services -l <label-key>=<label-value>

# Delete all pods, including uninitialized ones.
kubectl delete pods --all

Response: This text code Command line tool (kubectl) | kubectl exec - Execute a command against a container in a pod.


Prompt:
Complete this text code:

# Get output from running 'date' from pod <pod-name>. By default, output is from the first container.
kubectl exec <pod-name> -- date

# Get output from running 'date' in container <container-name> of pod <pod-name>.

Response:
kubectl exec <pod-name> -c <container-name> -- date

# Get an interactive TTY and run /bin/bash from pod <pod-name>. By default, output is from the first container.
kubectl exec -ti <pod-name> -- /bin/bash

Context: Command line tool (kubectl) | kubectl logs - Print the logs for a container in a pod.


Prompt:
Explain this text code:

# Get output from running 'date' from pod <pod-name>. By default, output is from the first container.
kubectl exec <pod-name> -- date

# Get output from running 'date' in container <container-name> of pod <pod-name>.
kubectl exec <pod-name> -c <container-name> -- date

# Get an interactive TTY and run /bin/bash from pod <pod-name>. By default, output is from the first container.
kubectl exec -ti <pod-name> -- /bin/bash

Response: This text code Command line tool (kubectl) | kubectl logs - Print the logs for a container in a pod.


Prompt:
Complete this text code:

# Return a snapshot of the logs from pod <pod-name>.
kubectl logs <pod-name>

Response:
# Start streaming the logs from pod <pod-name>. This is similar to the 'tail -f' Linux command.
kubectl logs -f <pod-name>

Context: Command line tool (kubectl) | kubectl diff - View a diff of the proposed updates to a cluster.


Prompt:
Explain this text code:

# Return a snapshot of the logs from pod <pod-name>.
kubectl logs <pod-name>

# Start streaming the logs from pod <pod-name>. This is similar to the 'tail -f' Linux command.
kubectl logs -f <pod-name>

Response: This text code Command line tool (kubectl) | kubectl diff - View a diff of the proposed updates to a cluster.


Prompt:
Complete this text code:

# Diff resources included in "pod.json".
kubectl diff -f pod.json

Response:
# Diff file read from stdin.
cat service.yaml | kubectl diff -f -

Context: Command line tool (kubectl) | Use the following set of examples to help you familiarize yourself with writing and using kubectl plugins:


Prompt:
Explain this text code:

# Diff resources included in "pod.json".
kubectl diff -f pod.json

# Diff file read from stdin.
cat service.yaml | kubectl diff -f -

Response: This text code Command line tool (kubectl) | Use the following set of examples to help you familiarize yourself with writing and using kubectl plugins:


Prompt:
Explain this text code:

# create a simple plugin in any language and name the resulting executable file
# so that it begins with the prefix "kubectl-"
cat ./kubectl-hello

Response: This text code Command line tool (kubectl) | With a plugin written, let's make it executable:

Context: Command line tool (kubectl) | With a plugin written, let's make it executable:


Prompt:
Complete this text code:

#!/bin/sh

Response:
# this plugin prints the words "hello world"
echo "hello world"


Prompt:
Explain this text code:

#!/bin/sh

# this plugin prints the words "hello world"
echo "hello world"

Response: This text code Command line tool (kubectl) | With a plugin written, let's make it executable:


Prompt:
Complete this text code:

chmod a+x ./kubectl-hello

# and move it to a location in our PATH
sudo mv ./kubectl-hello /usr/local/bin

Response:
sudo chown root:root /usr/local/bin

# You have now created and "installed" a kubectl plugin.
# You can begin using this plugin by invoking it from kubectl as if it were a regular command
kubectl hello

Context: Command line tool (kubectl) | In order to view all of the plugins that are available to kubectl, use the kubectl plugin list subcommand:


Prompt:
Explain this text code:

chmod a+x ./kubectl-hello

# and move it to a location in our PATH
sudo mv ./kubectl-hello /usr/local/bin
sudo chown root:root /usr/local/bin

# You have now created and "installed" a kubectl plugin.
# You can begin using this plugin by invoking it from kubectl as if it were a regular command
kubectl hello

Response: This text code Command line tool (kubectl) | In order to view all of the plugins that are available to kubectl, use the kubectl plugin list subcommand:


Prompt:
Explain this text code:

# You can "uninstall" a plugin, by removing it from the folder in your
# $PATH where you placed it
sudo rm /usr/local/bin/kubectl-hello

Response: This text code Command line tool (kubectl) | In order to view all of the plugins that are available to kubectl, use the kubectl plugin list subcommand:


Prompt:
Explain this text code:

sudo chmod -x /usr/local/bin/kubectl-foo # remove execute permission
kubectl plugin list

Response: This text code Command line tool (kubectl) | You can think of plugins as a means to build more complex functionality on top of the existing kubectl commands:


Prompt:
Complete this text code:

#!/bin/bash

Response:
# this plugin makes use of the `kubectl config` command in order to output
# information about the current user, based on the currently selected context
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'


Prompt:
Explain this text code:

#!/bin/bash

# this plugin makes use of the `kubectl config` command in order to output
# information about the current user, based on the currently selected context
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'

Response: This text code Command line tool (kubectl) | Running the above command gives you an output containing the user for the current context in your KUBECONFIG file:


Prompt:
Complete this text code:

# make the file executable
sudo chmod +x ./kubectl-whoami

# and move it into your PATH

Response:
sudo mv ./kubectl-whoami /usr/local/bin

kubectl whoami
Current user: plugins-user

Context: Command line tool (kubectl) |


Prompt:
Explain this text code:

# make the file executable
sudo chmod +x ./kubectl-whoami

# and move it into your PATH
sudo mv ./kubectl-whoami /usr/local/bin

kubectl whoami
Current user: plugins-user

Response: This text code Command line tool (kubectl) |

Context: Command line tool (kubectl) |


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:

Response:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json

Context: Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json

Response: This yaml code Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Complete this json code:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "defaultErrnoRet": 38,
  "syscalls": [
    {
      "names": [
        "adjtimex",
        "alarm",
        "bind",

Response:
        "waitid",
        "waitpid",
        "write",
        "writev"
      ],
      "action": "SCMP_ACT_ALLOW"
    }
  ]
}

Context: Seccomp and Kubernetes | The defaultAction in the profile above is defined as SCMP_ACT_ERRNO and will return as fallback to the actions defined in syscalls. The error is defined as code 38 via the defaultErrnoRet field.


Prompt:
Explain this json code:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "defaultErrnoRet": 38,
  "syscalls": [
    {
      "names": [
        "adjtimex",
        "alarm",
        "bind",
        "waitid",
        "waitpid",
        "write",
        "writev"
      ],
      "action": "SCMP_ACT_ALLOW"
    }
  ]
}

Response: This json code Seccomp and Kubernetes | The defaultAction in the profile above is defined as SCMP_ACT_ERRNO and will return as fallback to the actions defined in syscalls. The error is defined as code 38 via the defaultErrnoRet field.


Prompt:
Explain this text code:

spec.initContainers[*].securityContext.seccompProfile

Response: This text code Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Explain this text code:

spec.ephemeralContainers[*].securityContext.seccompProfile

Response: This text code Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:

Response:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json

Response: This yaml code Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Complete this json code:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "defaultErrnoRet": 38,
  "syscalls": [
    {
      "names": [
        "adjtimex",
        "alarm",
        "bind",

Response:
        "waitid",
        "waitpid",
        "write",
        "writev"
      ],
      "action": "SCMP_ACT_ALLOW"
    }
  ]
}


Prompt:
Explain this json code:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "defaultErrnoRet": 38,
  "syscalls": [
    {
      "names": [
        "adjtimex",
        "alarm",
        "bind",
        "waitid",
        "waitpid",
        "write",
        "writev"
      ],
      "action": "SCMP_ACT_ALLOW"
    }
  ]
}

Response: This json code Seccomp and Kubernetes | The defaultAction in the profile above is defined as SCMP_ACT_ERRNO and will return as fallback to the actions defined in syscalls. The error is defined as code 38 via the defaultErrnoRet field.


Prompt:
Complete this yaml code:

pods/security/seccomp/fields.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:

Response:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json


Prompt:
Explain this yaml code:

pods/security/seccomp/fields.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json

Response: This yaml code Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:

Response:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  ephemeralContainers:
  - name: ephemeral-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  initContainers:
  - name: init-container
    image: debian
    securityContext:
      seccompProfile:
        type: RuntimeDefault
  containers:
  - name: container
    image: docker.io/library/debian:stable
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: my-profile.json

Response: This yaml code Seccomp and Kubernetes | The Pod in the example above runs as Unconfined, while the ephemeral-container and init-container specifically defines RuntimeDefault. If the ephemeral or init container would not have set the securit


Prompt:
Complete this json code:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "defaultErrnoRet": 38,
  "syscalls": [
    {
      "names": [
        "adjtimex",
        "alarm",
        "bind",

Response:
        "waitid",
        "waitpid",
        "write",
        "writev"
      ],
      "action": "SCMP_ACT_ALLOW"
    }
  ]
}


Prompt:
Explain this json code:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "defaultErrnoRet": 38,
  "syscalls": [
    {
      "names": [
        "adjtimex",
        "alarm",
        "bind",
        "waitid",
        "waitpid",
        "write",
        "writev"
      ],
      "action": "SCMP_ACT_ALLOW"
    }
  ]
}

Response: This json code Seccomp and Kubernetes | The defaultAction in the profile above is defined as SCMP_ACT_ERRNO and will return as fallback to the actions defined in syscalls. The error is defined as code 38 via the defaultErrnoRet field.


Prompt:
Complete this text code:

200 OK
Content-Type: application/json

Response: … JSON encoded collection of Pods (PodList object)

Context: Kubernetes API Concepts | Create a pod by sending JSON to the server, requesting a JSON response.


Prompt:
Explain this text code:

200 OK
Content-Type: application/json

… JSON encoded collection of Pods (PodList object)

Response: This text code Kubernetes API Concepts | Create a pod by sending JSON to the server, requesting a JSON response.


Prompt:
Complete this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/json

Response:
Accept: application/json
… JSON encoded Pod object

Context: Kubernetes API Concepts | Kubernetes also supports the application/yaml media type for both requests and responses. YAML can be used for defining Kubernetes manifests and API interactions.


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/json
Accept: application/json
… JSON encoded Pod object

Response: This text code Kubernetes API Concepts | Kubernetes also supports the application/yaml media type for both requests and responses. YAML can be used for defining Kubernetes manifests and API interactions.


Prompt:
Complete this text code:

200 OK
Content-Type: application/json

{

Response:
  "kind": "Pod",
  "apiVersion": "v1",
  …
}


Prompt:
Explain this text code:

200 OK
Content-Type: application/json

{
  "kind": "Pod",
  "apiVersion": "v1",
  …
}

Response: This text code Kubernetes API Concepts | Kubernetes also supports the application/yaml media type for both requests and responses. YAML can be used for defining Kubernetes manifests and API interactions.


Prompt:
Complete this text code:

200 OK
Content-Type: application/yaml

Response: … YAML encoded collection of Pods (PodList object)

Context: Kubernetes API Concepts | Create a pod by sending YAML-encoded data to the server, requesting a YAML response:


Prompt:
Explain this text code:

200 OK
Content-Type: application/yaml

… YAML encoded collection of Pods (PodList object)

Response: This text code Kubernetes API Concepts | Create a pod by sending YAML-encoded data to the server, requesting a YAML response:


Prompt:
Complete this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/yaml

Response:
Accept: application/yaml
… YAML encoded Pod object

Context: Kubernetes API Concepts | Kubernetes uses an envelope wrapper to encode Protobuf responses. That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf (as opposed to JSON). The 4 byt


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/yaml
Accept: application/yaml
… YAML encoded Pod object

Response: This text code Kubernetes API Concepts | Kubernetes uses an envelope wrapper to encode Protobuf responses. That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf (as opposed to JSON). The 4 byt


Prompt:
Complete this yaml code:

200 OK
Content-Type: application/yaml

apiVersion: v1

Response:
kind: Pod
metadata:
  name: my-pod
  …


Prompt:
Explain this yaml code:

200 OK
Content-Type: application/yaml

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  …

Response: This yaml code Kubernetes API Concepts | Kubernetes uses an envelope wrapper to encode Protobuf responses. That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf (as opposed to JSON). The 4 byt


Prompt:
Explain this text code:

GET /api/v1/pods
Accept: application/vnd.kubernetes.protobuf

Response: This text code Kubernetes API Concepts | Create a pod by sending Protobuf encoded data to the server, but request a response in JSON.

Context: Kubernetes API Concepts | Create a pod by sending Protobuf encoded data to the server, but request a response in JSON.


Prompt:
Complete this text code:

200 OK
Content-Type: application/vnd.kubernetes.protobuf

Response: … binary encoded collection of Pods (PodList object)


Prompt:
Explain this text code:

200 OK
Content-Type: application/vnd.kubernetes.protobuf

… binary encoded collection of Pods (PodList object)

Response: This text code Kubernetes API Concepts | Create a pod by sending Protobuf encoded data to the server, but request a response in JSON.


Prompt:
Complete this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/vnd.kubernetes.protobuf

Response:
Accept: application/json
… binary encoded Pod object

Context: Kubernetes API Concepts | You can use both techniques together and use Kubernetes' Protobuf encoding to interact with any API that supports it, for both reads and writes. Only some API resource types are compatible with Protob


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/vnd.kubernetes.protobuf
Accept: application/json
… binary encoded Pod object

Response: This text code Kubernetes API Concepts | You can use both techniques together and use Kubernetes' Protobuf encoding to interact with any API that supports it, for both reads and writes. Only some API resource types are compatible with Protob


Prompt:
Complete this text code:

200 OK
Content-Type: application/json

{

Response:
  "kind": "Pod",
  "apiVersion": "v1",
  ...
}


Prompt:
Explain this text code:

200 OK
Content-Type: application/json

{
  "kind": "Pod",
  "apiVersion": "v1",
  ...
}

Response: This text code Kubernetes API Concepts | You can use both techniques together and use Kubernetes' Protobuf encoding to interact with any API that supports it, for both reads and writes. Only some API resource types are compatible with Protob


Prompt:
Complete this text code:

A four byte magic number prefix:
  Bytes 0-3: "k8s\x00" [0x6b, 0x38, 0x73, 0x00]

An encoded Protobuf message with the following IDL:
  message Unknown {
    // typeMeta should have the string values for "kind" and "apiVersion" as set on the JSON object
    optional TypeMeta typeMeta = 1;

    // raw will hold the complete serialized object in protobuf. See the protobuf definitions in the client libraries for a given kind.
    optional bytes raw = 2;

    // contentEncoding is encoding used for the raw data. Unspecified means no encoding.

Response:
    optional string contentEncoding = 3;

    // contentType is the serialization method used to serialize 'raw'. Unspecified means application/vnd.kubernetes.protobuf and is usually
    // omitted.
    optional string contentType = 4;
  }

  message TypeMeta {
    // apiVersion is the group/version for this type
    optional string apiVersion = 1;
    // kind is the name of the object schema. A protobuf definition should exist for this object.
    optional string kind = 2;
  }

Context: Kubernetes API Concepts | Not all API resource types support Kubernetes' Protobuf encoding; specifically, Protobuf isn't available for resources that are defined as CustomResourceDefinitions or are served via the aggregation l


Prompt:
Explain this text code:

A four byte magic number prefix:
  Bytes 0-3: "k8s\x00" [0x6b, 0x38, 0x73, 0x00]

An encoded Protobuf message with the following IDL:
  message Unknown {
    // typeMeta should have the string values for "kind" and "apiVersion" as set on the JSON object
    optional TypeMeta typeMeta = 1;

    // raw will hold the complete serialized object in protobuf. See the protobuf definitions in the client libraries for a given kind.
    optional bytes raw = 2;

    // contentEncoding is encoding used for the raw data. Unspecified means no encoding.
    optional string contentEncoding = 3;

    // contentType is the serialization method used to serialize 'raw'. Unspecified means application/vnd.kubernetes.protobuf and is usually
    // omitted.
    optional string contentType = 4;
  }

  message TypeMeta {
    // apiVersion is the group/version for this type
    optional string apiVersion = 1;
    // kind is the name of the object schema. A protobuf definition should exist for this object.
    optional string kind = 2;
  }

Response: This text code Kubernetes API Concepts | Not all API resource types support Kubernetes' Protobuf encoding; specifically, Protobuf isn't available for resources that are defined as CustomResourceDefinitions or are served via the aggregation l


Prompt:
Explain this text code:

Accept: application/vnd.kubernetes.protobuf, application/json

Response: This text code Kubernetes API Concepts | With the CBORServingAndStorage feature gate enabled, request and response bodies for all built-in resource types and all resources defined by a CustomResourceDefinition may be encoded to the CBOR bina

Context: Kubernetes API Concepts | With the CBORServingAndStorage feature gate enabled, request and response bodies for all built-in resource types and all resources defined by a CustomResourceDefinition may be encoded to the CBOR bina


Prompt:
Complete this text code:

GET /api/v1/namespaces/test/pods
---
200 OK
Content-Type: application/json

Response:
{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {"resourceVersion":"10245"},
  "items": [...]
}

Context: Kubernetes API Concepts | Starting from resource version 10245, receive notifications of any API operations (such as create, delete, patch or update) that affect Pods in the test namespace. Each change notification is a JSON d


Prompt:
Explain this text code:

GET /api/v1/namespaces/test/pods
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {"resourceVersion":"10245"},
  "items": [...]
}

Response: This text code Kubernetes API Concepts | Starting from resource version 10245, receive notifications of any API operations (such as create, delete, patch or update) that affect Pods in the test namespace. Each change notification is a JSON d


Prompt:
Complete this text code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{

Response:
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
{
  "type": "MODIFIED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "11020", ...}, ...}
}
...

Context: Kubernetes API Concepts | A given Kubernetes server will only preserve a historical record of changes for a limited time. Clusters using etcd 3 preserve changes in the last 5 minutes by default. When the requested watch operat


Prompt:
Explain this text code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
{
  "type": "MODIFIED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "11020", ...}, ...}
}
...

Response: This text code Kubernetes API Concepts | A given Kubernetes server will only preserve a historical record of changes for a limited time. Clusters using etcd 3 preserve changes in the last 5 minutes by default. When the requested watch operat


Prompt:
Complete this text code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245&allowWatchBookmarks=true
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{

Response:
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
...
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "12746"} }
}

Context: Kubernetes API Concepts | As a client, you can request BOOKMARK events by setting the allowWatchBookmarks=true query parameter to a watch request, but you shouldn't assume bookmarks are returned at any specific interval, nor c


Prompt:
Explain this text code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245&allowWatchBookmarks=true
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
...
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "12746"} }
}

Response: This text code Kubernetes API Concepts | As a client, you can request BOOKMARK events by setting the allowWatchBookmarks=true query parameter to a watch request, but you shouldn't assume bookmarks are returned at any specific interval, nor c


Prompt:
Complete this text code:

GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
}

Response:
{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
}
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
}
...
<followed by regular watch stream starting from resourceVersion="10245">

Context: Kubernetes API Concepts | APIResponseCompression is an option that allows the API server to compress the responses for get and list requests, reducing the network bandwidth and improving the performance of large-scale clusters


Prompt:
Explain this text code:

GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
}
{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
}
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
}
...
<followed by regular watch stream starting from resourceVersion="10245">

Response: This text code Kubernetes API Concepts | APIResponseCompression is an option that allows the API server to compress the responses for get and list requests, reducing the network bandwidth and improving the performance of large-scale clusters


Prompt:
Complete this text code:

GET /api/v1/pods
Accept-Encoding: gzip
---

Response:
200 OK
Content-Type: application/json
content-encoding: gzip
...

Context: Kubernetes API Concepts | The content-encoding header indicates that the response is compressed with gzip.


Prompt:
Explain this text code:

GET /api/v1/pods
Accept-Encoding: gzip
---
200 OK
Content-Type: application/json
content-encoding: gzip
...

Response: This text code Kubernetes API Concepts | The content-encoding header indicates that the response is compressed with gzip.


Prompt:
Complete this text code:

GET /api/v1/pods?limit=500
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",

Response:
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN",
    "remainingItemCount": 753,
    ...
  },
  "items": [...] // returns pods 1-500
}

Context: Kubernetes API Concepts | Continue the previous call, retrieving the next set of 500 pods.


Prompt:
Explain this text code:

GET /api/v1/pods?limit=500
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN",
    "remainingItemCount": 753,
    ...
  },
  "items": [...] // returns pods 1-500
}

Response: This text code Kubernetes API Concepts | Continue the previous call, retrieving the next set of 500 pods.


Prompt:
Complete this text code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",

Response:
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN_2",
    "remainingItemCount": 253,
    ...
  },
  "items": [...] // returns pods 501-1000
}

Context: Kubernetes API Concepts | Continue the previous call, retrieving the last 253 pods.


Prompt:
Explain this text code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN_2",
    "remainingItemCount": 253,
    ...
  },
  "items": [...] // returns pods 501-1000
}

Response: This text code Kubernetes API Concepts | Continue the previous call, retrieving the last 253 pods.


Prompt:
Complete this text code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN_2
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",

Response:
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "", // continue token is empty because we have reached the end of the list
    ...
  },
  "items": [...] // returns pods 1001-1253
}

Context: Kubernetes API Concepts | Notice that the resourceVersion of the collection remains constant across each request, indicating the server is showing you a consistent snapshot of the pods. Pods that are created, updated, or delet


Prompt:
Explain this text code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN_2
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "", // continue token is empty because we have reached the end of the list
    ...
  },
  "items": [...] // returns pods 1001-1253
}

Response: This text code Kubernetes API Concepts | Notice that the resourceVersion of the collection remains constant across each request, indicating the server is showing you a consistent snapshot of the pods. Pods that are created, updated, or delet


Prompt:
Complete this json code:

{
  "kind": "ServiceList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion": "2947301"
  },
  "items": [
    {

Response:
      "metadata": {
        "name": "kubernetes",
        "namespace": "default",
...
      "metadata": {
        "name": "kube-dns",
        "namespace": "kube-system",
...

Context: Kubernetes API Concepts | There are dozens of collection types (such as PodList, ServiceList, and NodeList) defined in the Kubernetes API. You can get more information about each collection type from the Kubernetes API documen


Prompt:
Explain this json code:

{
  "kind": "ServiceList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion": "2947301"
  },
  "items": [
    {
      "metadata": {
        "name": "kubernetes",
        "namespace": "default",
...
      "metadata": {
        "name": "kube-dns",
        "namespace": "kube-system",
...

Response: This json code Kubernetes API Concepts | There are dozens of collection types (such as PodList, ServiceList, and NodeList) defined in the Kubernetes API. You can get more information about each collection type from the Kubernetes API documen


Prompt:
Complete this yaml code:

apiVersion: v1
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
items:
- apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: "2021-06-03T14:54:12Z"
    labels:
      component: apiserver
      provider: kubernetes
    name: kubernetes

Response:
    namespace: default
...
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      prometheus.io/port: "9153"
      prometheus.io/scrape: "true"
    creationTimestamp: "2021-06-03T14:54:14Z"
    labels:
      k8s-app: kube-dns
      kubernetes.io/cluster-service: "true"
      kubernetes.io/name: CoreDNS
    name: kube-dns
    namespace: kube-system

Context: Kubernetes API Concepts | Keep in mind that the Kubernetes API does not have a kind named List.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
items:
- apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: "2021-06-03T14:54:12Z"
    labels:
      component: apiserver
      provider: kubernetes
    name: kubernetes
    namespace: default
...
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      prometheus.io/port: "9153"
      prometheus.io/scrape: "true"
    creationTimestamp: "2021-06-03T14:54:14Z"
    labels:
      k8s-app: kube-dns
      kubernetes.io/cluster-service: "true"
      kubernetes.io/name: CoreDNS
    name: kube-dns
    namespace: kube-system

Response: This yaml code Kubernetes API Concepts | Keep in mind that the Kubernetes API does not have a kind named List.


Prompt:
Complete this text code:

GET /api/v1/pods
Accept: application/json;as=Table;g=meta.k8s.io;v=v1
---
200 OK
Content-Type: application/json

{

Response:
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [
        ...
    ]
}

Context: Kubernetes API Concepts | For API resource types that do not have a custom Table definition known to the control plane, the API server returns a default Table response that consists of the resource's name and creationTimestamp


Prompt:
Explain this text code:

GET /api/v1/pods
Accept: application/json;as=Table;g=meta.k8s.io;v=v1
---
200 OK
Content-Type: application/json

{
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [
        ...
    ]
}

Response: This text code Kubernetes API Concepts | For API resource types that do not have a custom Table definition known to the control plane, the API server returns a default Table response that consists of the resource's name and creationTimestamp


Prompt:
Complete this text code:

GET /apis/crd.example.com/v1alpha1/namespaces/default/resources
---
200 OK
Content-Type: application/json
...

{
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [

Response:
        {
            "name": "Name",
            "type": "string",
            ...
        },
        {
            "name": "Created At",
            "type": "date",
            ...
        }
    ]
}

Context: Kubernetes API Concepts | Not all API resource types support a Table response; for example, a CustomResourceDefinitions might not define field-to-table mappings, and an APIService that extends the core Kubernetes API might not


Prompt:
Explain this text code:

GET /apis/crd.example.com/v1alpha1/namespaces/default/resources
---
200 OK
Content-Type: application/json
...

{
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [
        {
            "name": "Name",
            "type": "string",
            ...
        },
        {
            "name": "Created At",
            "type": "date",
            ...
        }
    ]
}

Response: This text code Kubernetes API Concepts | Not all API resource types support a Table response; for example, a CustomResourceDefinitions might not define field-to-table mappings, and an APIService that extends the core Kubernetes API might not


Prompt:
Explain this text code:

Accept: application/json;as=Table;g=meta.k8s.io;v=v1, application/json

Response: This text code Kubernetes API Concepts | When you delete a resource this takes place in two phases.

Context: Kubernetes API Concepts | When you delete a resource this takes place in two phases.


Prompt:
Complete this json code:

{
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {

Response:
    "finalizers": ["url.io/neat-finalization", "other-url.io/my-finalizer"],
    "deletionTimestamp": nil,
  }
}

Context: Kubernetes API Concepts | When a client first sends a delete to request the removal of a resource, the .metadata.deletionTimestamp is set to the current time. Once the .metadata.deletionTimestamp is set, external controllers t


Prompt:
Explain this json code:

{
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {
    "finalizers": ["url.io/neat-finalization", "other-url.io/my-finalizer"],
    "deletionTimestamp": nil,
  }
}

Response: This json code Kubernetes API Concepts | When a client first sends a delete to request the removal of a resource, the .metadata.deletionTimestamp is set to the current time. Once the .metadata.deletionTimestamp is set, external controllers t


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods?dryRun=All
Content-Type: application/json
Accept: application/json

Response: This text code Kubernetes API Concepts | The response would look the same as for non-dry-run request, but the values of some generated fields may differ.

Context: Kubernetes API Concepts | The response would look the same as for non-dry-run request, but the values of some generated fields may differ.


Prompt:
Complete this text code:

rules:
- apiGroups: ["apps"]

Response:
  resources: ["deployments"]
  verbs: ["patch"]

Context: Kubernetes API Concepts | See Authorization Overview.


Prompt:
Explain this text code:

rules:
- apiGroups: ["apps"]
  resources: ["deployments"]
  verbs: ["patch"]

Response: This text code Kubernetes API Concepts | See Authorization Overview.


Prompt:
Explain this text code:

/apis/apps/v1/namespaces/my-namespace/deployments/my-deployment

Response: This text code Kubernetes API Concepts | You can also access collections of resources (for example: listing all Nodes). The following paths are used to retrieve collections and resources:

Context: Kubernetes API Concepts | You can also access collections of resources (for example: listing all Nodes). The following paths are used to retrieve collections and resources:


Prompt:
Explain this text code:

GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE

Response: This text code Kubernetes API Concepts | Since a namespace is a cluster-scoped resource type, you can retrieve the list (“collection”) of all namespaces with GET /api/v1/namespaces and details about a particular namespace with GET /api/v1/na

Context: Kubernetes API Concepts | Since a namespace is a cluster-scoped resource type, you can retrieve the list (“collection”) of all namespaces with GET /api/v1/namespaces and details about a particular namespace with GET /api/v1/na


Prompt:
Explain this text code:

GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME

Response: This text code Kubernetes API Concepts | Since a namespace is a cluster-scoped resource type, you can retrieve the list (“collection”) of all namespaces with GET /api/v1/namespaces and details about a particular namespace with GET /api/v1/na


Prompt:
Explain this text code:

GET /apis/GROUP/VERSION/RESOURCETYPE/NAME/SUBRESOURCE

Response: This text code Kubernetes API Concepts | The verbs supported for each subresource will differ depending on the object - see the API reference for more information. It is not possible to access sub-resources across multiple resources - genera

Context: Kubernetes API Concepts | The verbs supported for each subresource will differ depending on the object - see the API reference for more information. It is not possible to access sub-resources across multiple resources - genera


Prompt:
Explain this text code:

GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME/SUBRESOURCE

Response: This text code Kubernetes API Concepts | The verbs supported for each subresource will differ depending on the object - see the API reference for more information. It is not possible to access sub-resources across multiple resources - genera


Prompt:
Complete this text code:

200 OK
Content-Type: application/json

Response: … JSON encoded collection of Pods (PodList object)

Context: Kubernetes API Concepts | Create a pod by sending JSON to the server, requesting a JSON response.


Prompt:
Explain this text code:

200 OK
Content-Type: application/json

… JSON encoded collection of Pods (PodList object)

Response: This text code Kubernetes API Concepts | Create a pod by sending JSON to the server, requesting a JSON response.


Prompt:
Complete this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/json

Response:
Accept: application/json
… JSON encoded Pod object

Context: Kubernetes API Concepts | Kubernetes also supports the application/yaml media type for both requests and responses. YAML can be used for defining Kubernetes manifests and API interactions.


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/json
Accept: application/json
… JSON encoded Pod object

Response: This text code Kubernetes API Concepts | Kubernetes also supports the application/yaml media type for both requests and responses. YAML can be used for defining Kubernetes manifests and API interactions.


Prompt:
Complete this text code:

200 OK
Content-Type: application/json

{

Response:
  "kind": "Pod",
  "apiVersion": "v1",
  …
}


Prompt:
Explain this text code:

200 OK
Content-Type: application/json

{
  "kind": "Pod",
  "apiVersion": "v1",
  …
}

Response: This text code Kubernetes API Concepts | Kubernetes also supports the application/yaml media type for both requests and responses. YAML can be used for defining Kubernetes manifests and API interactions.


Prompt:
Complete this text code:

200 OK
Content-Type: application/yaml

Response: … YAML encoded collection of Pods (PodList object)

Context: Kubernetes API Concepts | Create a pod by sending YAML-encoded data to the server, requesting a YAML response:


Prompt:
Explain this text code:

200 OK
Content-Type: application/yaml

… YAML encoded collection of Pods (PodList object)

Response: This text code Kubernetes API Concepts | Create a pod by sending YAML-encoded data to the server, requesting a YAML response:


Prompt:
Complete this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/yaml

Response:
Accept: application/yaml
… YAML encoded Pod object

Context: Kubernetes API Concepts | Kubernetes uses an envelope wrapper to encode Protobuf responses. That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf (as opposed to JSON). The 4 byt


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/yaml
Accept: application/yaml
… YAML encoded Pod object

Response: This text code Kubernetes API Concepts | Kubernetes uses an envelope wrapper to encode Protobuf responses. That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf (as opposed to JSON). The 4 byt


Prompt:
Complete this yaml code:

200 OK
Content-Type: application/yaml

apiVersion: v1

Response:
kind: Pod
metadata:
  name: my-pod
  …


Prompt:
Explain this yaml code:

200 OK
Content-Type: application/yaml

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  …

Response: This yaml code Kubernetes API Concepts | Kubernetes uses an envelope wrapper to encode Protobuf responses. That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf (as opposed to JSON). The 4 byt


Prompt:
Explain this text code:

GET /api/v1/pods
Accept: application/vnd.kubernetes.protobuf

Response: This text code Kubernetes API Concepts | Create a pod by sending Protobuf encoded data to the server, but request a response in JSON.

Context: Kubernetes API Concepts | Create a pod by sending Protobuf encoded data to the server, but request a response in JSON.


Prompt:
Complete this text code:

200 OK
Content-Type: application/vnd.kubernetes.protobuf

Response: … binary encoded collection of Pods (PodList object)


Prompt:
Explain this text code:

200 OK
Content-Type: application/vnd.kubernetes.protobuf

… binary encoded collection of Pods (PodList object)

Response: This text code Kubernetes API Concepts | Create a pod by sending Protobuf encoded data to the server, but request a response in JSON.


Prompt:
Complete this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/vnd.kubernetes.protobuf

Response:
Accept: application/json
… binary encoded Pod object

Context: Kubernetes API Concepts | You can use both techniques together and use Kubernetes' Protobuf encoding to interact with any API that supports it, for both reads and writes. Only some API resource types are compatible with Protob


Prompt:
Explain this text code:

POST /api/v1/namespaces/test/pods
Content-Type: application/vnd.kubernetes.protobuf
Accept: application/json
… binary encoded Pod object

Response: This text code Kubernetes API Concepts | You can use both techniques together and use Kubernetes' Protobuf encoding to interact with any API that supports it, for both reads and writes. Only some API resource types are compatible with Protob


Prompt:
Complete this text code:

200 OK
Content-Type: application/json

{

Response:
  "kind": "Pod",
  "apiVersion": "v1",
  ...
}


Prompt:
Explain this text code:

200 OK
Content-Type: application/json

{
  "kind": "Pod",
  "apiVersion": "v1",
  ...
}

Response: This text code Kubernetes API Concepts | You can use both techniques together and use Kubernetes' Protobuf encoding to interact with any API that supports it, for both reads and writes. Only some API resource types are compatible with Protob


Prompt:
Complete this text code:

A four byte magic number prefix:
  Bytes 0-3: "k8s\x00" [0x6b, 0x38, 0x73, 0x00]

An encoded Protobuf message with the following IDL:
  message Unknown {
    // typeMeta should have the string values for "kind" and "apiVersion" as set on the JSON object
    optional TypeMeta typeMeta = 1;

    // raw will hold the complete serialized object in protobuf. See the protobuf definitions in the client libraries for a given kind.
    optional bytes raw = 2;

    // contentEncoding is encoding used for the raw data. Unspecified means no encoding.

Response:
    optional string contentEncoding = 3;

    // contentType is the serialization method used to serialize 'raw'. Unspecified means application/vnd.kubernetes.protobuf and is usually
    // omitted.
    optional string contentType = 4;
  }

  message TypeMeta {
    // apiVersion is the group/version for this type
    optional string apiVersion = 1;
    // kind is the name of the object schema. A protobuf definition should exist for this object.
    optional string kind = 2;
  }

Context: Kubernetes API Concepts | Not all API resource types support Kubernetes' Protobuf encoding; specifically, Protobuf isn't available for resources that are defined as CustomResourceDefinitions or are served via the aggregation l


Prompt:
Explain this text code:

A four byte magic number prefix:
  Bytes 0-3: "k8s\x00" [0x6b, 0x38, 0x73, 0x00]

An encoded Protobuf message with the following IDL:
  message Unknown {
    // typeMeta should have the string values for "kind" and "apiVersion" as set on the JSON object
    optional TypeMeta typeMeta = 1;

    // raw will hold the complete serialized object in protobuf. See the protobuf definitions in the client libraries for a given kind.
    optional bytes raw = 2;

    // contentEncoding is encoding used for the raw data. Unspecified means no encoding.
    optional string contentEncoding = 3;

    // contentType is the serialization method used to serialize 'raw'. Unspecified means application/vnd.kubernetes.protobuf and is usually
    // omitted.
    optional string contentType = 4;
  }

  message TypeMeta {
    // apiVersion is the group/version for this type
    optional string apiVersion = 1;
    // kind is the name of the object schema. A protobuf definition should exist for this object.
    optional string kind = 2;
  }

Response: This text code Kubernetes API Concepts | Not all API resource types support Kubernetes' Protobuf encoding; specifically, Protobuf isn't available for resources that are defined as CustomResourceDefinitions or are served via the aggregation l


Prompt:
Explain this text code:

Accept: application/vnd.kubernetes.protobuf, application/json

Response: This text code Kubernetes API Concepts | With the CBORServingAndStorage feature gate enabled, request and response bodies for all built-in resource types and all resources defined by a CustomResourceDefinition may be encoded to the CBOR bina

Context: Kubernetes API Concepts | With the CBORServingAndStorage feature gate enabled, request and response bodies for all built-in resource types and all resources defined by a CustomResourceDefinition may be encoded to the CBOR bina


Prompt:
Complete this http code:

GET /api/v1/namespaces/test/pods
---
200 OK
Content-Type: application/json

Response:
{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {"resourceVersion":"10245"},
  "items": [...]
}

Context: Kubernetes API Concepts | Starting from resource version 10245, receive notifications of any API operations (such as create, delete, patch or update) that affect Pods in the test namespace. Each change notification is a JSON d


Prompt:
Explain this http code:

GET /api/v1/namespaces/test/pods
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {"resourceVersion":"10245"},
  "items": [...]
}

Response: This http code Kubernetes API Concepts | Starting from resource version 10245, receive notifications of any API operations (such as create, delete, patch or update) that affect Pods in the test namespace. Each change notification is a JSON d


Prompt:
Complete this http code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{

Response:
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
{
  "type": "MODIFIED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "11020", ...}, ...}
}
...

Context: Kubernetes API Concepts | A given Kubernetes server will only preserve a historical record of changes for a limited time. Clusters using etcd 3 preserve changes in the last 5 minutes by default. When the requested watch operat


Prompt:
Explain this http code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
{
  "type": "MODIFIED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "11020", ...}, ...}
}
...

Response: This http code Kubernetes API Concepts | A given Kubernetes server will only preserve a historical record of changes for a limited time. Clusters using etcd 3 preserve changes in the last 5 minutes by default. When the requested watch operat


Prompt:
Complete this http code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245&allowWatchBookmarks=true
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{

Response:
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
...
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "12746"} }
}

Context: Kubernetes API Concepts | As a client, you can request BOOKMARK events by setting the allowWatchBookmarks=true query parameter to a watch request, but you shouldn't assume bookmarks are returned at any specific interval, nor c


Prompt:
Explain this http code:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245&allowWatchBookmarks=true
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
...
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "12746"} }
}

Response: This http code Kubernetes API Concepts | As a client, you can request BOOKMARK events by setting the allowWatchBookmarks=true query parameter to a watch request, but you shouldn't assume bookmarks are returned at any specific interval, nor c


Prompt:
Complete this http code:

GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
}

Response:
{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
}
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
}
...
<followed by regular watch stream starting from resourceVersion="10245">

Context: Kubernetes API Concepts | APIResponseCompression is an option that allows the API server to compress the responses for get and list requests, reducing the network bandwidth and improving the performance of large-scale clusters


Prompt:
Explain this http code:

GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json

{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
}
{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
}
{
  "type": "BOOKMARK",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
}
...
<followed by regular watch stream starting from resourceVersion="10245">

Response: This http code Kubernetes API Concepts | APIResponseCompression is an option that allows the API server to compress the responses for get and list requests, reducing the network bandwidth and improving the performance of large-scale clusters


Prompt:
Complete this http code:

GET /api/v1/pods
Accept-Encoding: gzip
---

Response:
200 OK
Content-Type: application/json
content-encoding: gzip
...

Context: Kubernetes API Concepts | The content-encoding header indicates that the response is compressed with gzip.


Prompt:
Explain this http code:

GET /api/v1/pods
Accept-Encoding: gzip
---
200 OK
Content-Type: application/json
content-encoding: gzip
...

Response: This http code Kubernetes API Concepts | The content-encoding header indicates that the response is compressed with gzip.


Prompt:
Complete this http code:

GET /api/v1/pods?limit=500
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",

Response:
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN",
    "remainingItemCount": 753,
    ...
  },
  "items": [...] // returns pods 1-500
}

Context: Kubernetes API Concepts | Continue the previous call, retrieving the next set of 500 pods.


Prompt:
Explain this http code:

GET /api/v1/pods?limit=500
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN",
    "remainingItemCount": 753,
    ...
  },
  "items": [...] // returns pods 1-500
}

Response: This http code Kubernetes API Concepts | Continue the previous call, retrieving the next set of 500 pods.


Prompt:
Complete this http code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",

Response:
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN_2",
    "remainingItemCount": 253,
    ...
  },
  "items": [...] // returns pods 501-1000
}

Context: Kubernetes API Concepts | Continue the previous call, retrieving the last 253 pods.


Prompt:
Explain this http code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "ENCODED_CONTINUE_TOKEN_2",
    "remainingItemCount": 253,
    ...
  },
  "items": [...] // returns pods 501-1000
}

Response: This http code Kubernetes API Concepts | Continue the previous call, retrieving the last 253 pods.


Prompt:
Complete this http code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN_2
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",

Response:
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "", // continue token is empty because we have reached the end of the list
    ...
  },
  "items": [...] // returns pods 1001-1253
}

Context: Kubernetes API Concepts | Notice that the resourceVersion of the collection remains constant across each request, indicating the server is showing you a consistent snapshot of the pods. Pods that are created, updated, or delet


Prompt:
Explain this http code:

GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN_2
---
200 OK
Content-Type: application/json

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion":"10245",
    "continue": "", // continue token is empty because we have reached the end of the list
    ...
  },
  "items": [...] // returns pods 1001-1253
}

Response: This http code Kubernetes API Concepts | Notice that the resourceVersion of the collection remains constant across each request, indicating the server is showing you a consistent snapshot of the pods. Pods that are created, updated, or delet


Prompt:
Complete this yaml code:

{
  "kind": "ServiceList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion": "2947301"
  },
  "items": [
    {

Response:
      "metadata": {
        "name": "kubernetes",
        "namespace": "default",
...
      "metadata": {
        "name": "kube-dns",
        "namespace": "kube-system",
...

Context: Kubernetes API Concepts | There are dozens of collection types (such as PodList, ServiceList, and NodeList) defined in the Kubernetes API. You can get more information about each collection type from the Kubernetes API documen


Prompt:
Explain this yaml code:

{
  "kind": "ServiceList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion": "2947301"
  },
  "items": [
    {
      "metadata": {
        "name": "kubernetes",
        "namespace": "default",
...
      "metadata": {
        "name": "kube-dns",
        "namespace": "kube-system",
...

Response: This yaml code Kubernetes API Concepts | There are dozens of collection types (such as PodList, ServiceList, and NodeList) defined in the Kubernetes API. You can get more information about each collection type from the Kubernetes API documen


Prompt:
Complete this yaml code:

apiVersion: v1
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
items:
- apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: "2021-06-03T14:54:12Z"
    labels:
      component: apiserver
      provider: kubernetes
    name: kubernetes

Response:
    namespace: default
...
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      prometheus.io/port: "9153"
      prometheus.io/scrape: "true"
    creationTimestamp: "2021-06-03T14:54:14Z"
    labels:
      k8s-app: kube-dns
      kubernetes.io/cluster-service: "true"
      kubernetes.io/name: CoreDNS
    name: kube-dns
    namespace: kube-system

Context: Kubernetes API Concepts | Keep in mind that the Kubernetes API does not have a kind named List.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
items:
- apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: "2021-06-03T14:54:12Z"
    labels:
      component: apiserver
      provider: kubernetes
    name: kubernetes
    namespace: default
...
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      prometheus.io/port: "9153"
      prometheus.io/scrape: "true"
    creationTimestamp: "2021-06-03T14:54:14Z"
    labels:
      k8s-app: kube-dns
      kubernetes.io/cluster-service: "true"
      kubernetes.io/name: CoreDNS
    name: kube-dns
    namespace: kube-system

Response: This yaml code Kubernetes API Concepts | Keep in mind that the Kubernetes API does not have a kind named List.


Prompt:
Complete this http code:

GET /api/v1/pods
Accept: application/json;as=Table;g=meta.k8s.io;v=v1
---
200 OK
Content-Type: application/json

{

Response:
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [
        ...
    ]
}

Context: Kubernetes API Concepts | For API resource types that do not have a custom Table definition known to the control plane, the API server returns a default Table response that consists of the resource's name and creationTimestamp


Prompt:
Explain this http code:

GET /api/v1/pods
Accept: application/json;as=Table;g=meta.k8s.io;v=v1
---
200 OK
Content-Type: application/json

{
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [
        ...
    ]
}

Response: This http code Kubernetes API Concepts | For API resource types that do not have a custom Table definition known to the control plane, the API server returns a default Table response that consists of the resource's name and creationTimestamp


Prompt:
Complete this http code:

GET /apis/crd.example.com/v1alpha1/namespaces/default/resources
---
200 OK
Content-Type: application/json
...

{
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [

Response:
        {
            "name": "Name",
            "type": "string",
            ...
        },
        {
            "name": "Created At",
            "type": "date",
            ...
        }
    ]
}

Context: Kubernetes API Concepts | Not all API resource types support a Table response; for example, a CustomResourceDefinitions might not define field-to-table mappings, and an APIService that extends the core Kubernetes API might not


Prompt:
Explain this http code:

GET /apis/crd.example.com/v1alpha1/namespaces/default/resources
---
200 OK
Content-Type: application/json
...

{
    "kind": "Table",
    "apiVersion": "meta.k8s.io/v1",
    ...
    "columnDefinitions": [
        {
            "name": "Name",
            "type": "string",
            ...
        },
        {
            "name": "Created At",
            "type": "date",
            ...
        }
    ]
}

Response: This http code Kubernetes API Concepts | Not all API resource types support a Table response; for example, a CustomResourceDefinitions might not define field-to-table mappings, and an APIService that extends the core Kubernetes API might not


Prompt:
Explain this text code:

Accept: application/json;as=Table;g=meta.k8s.io;v=v1, application/json

Response: This text code Kubernetes API Concepts | When you delete a resource this takes place in two phases.

Context: Kubernetes API Concepts | When you delete a resource this takes place in two phases.


Prompt:
Complete this yaml code:

{
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {

Response:
    "finalizers": ["url.io/neat-finalization", "other-url.io/my-finalizer"],
    "deletionTimestamp": nil,
  }
}

Context: Kubernetes API Concepts | When a client first sends a delete to request the removal of a resource, the .metadata.deletionTimestamp is set to the current time. Once the .metadata.deletionTimestamp is set, external controllers t


Prompt:
Explain this yaml code:

{
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {
    "finalizers": ["url.io/neat-finalization", "other-url.io/my-finalizer"],
    "deletionTimestamp": nil,
  }
}

Response: This yaml code Kubernetes API Concepts | When a client first sends a delete to request the removal of a resource, the .metadata.deletionTimestamp is set to the current time. Once the .metadata.deletionTimestamp is set, external controllers t