Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"

Response: This text code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because only limits are specified and requests are set equal to limits when not explicitly specified. And the container's resource limit for the CPU reso


Prompt:
Explain this text code:

concepts/policy/limit-range/problematic-limit-range.yaml

Response: This text code 1 - Limit Ranges | along with a Pod that declares a CPU resource request of 700m, but not a limit:

Context: 1 - Limit Ranges | along with a Pod that declares a CPU resource request of 700m, but not a limit:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-resource-constraint
spec:
  limits:
  - default: # this section defines default limits

Response:
      cpu: 500m
    defaultRequest: # this section defines default requests
      cpu: 500m
    max: # max and min define the limit range
      cpu: "1"
    min:
      cpu: 100m
    type: Container


Prompt:
Explain this yaml code:

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-resource-constraint
spec:
  limits:
  - default: # this section defines default limits
      cpu: 500m
    defaultRequest: # this section defines default requests
      cpu: 500m
    max: # max and min define the limit range
      cpu: "1"
    min:
      cpu: 100m
    type: Container

Response: This yaml code 1 - Limit Ranges | along with a Pod that declares a CPU resource request of 700m, but not a limit:


Prompt:
Explain this text code:

concepts/policy/limit-range/example-conflict-with-limitrange-cpu.yaml

Response: This text code 1 - Limit Ranges | then that Pod will not be scheduled, failing with an error similar to:

Context: 1 - Limit Ranges | then that Pod will not be scheduled, failing with an error similar to:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-conflict-with-limitrange-cpu
spec:

Response:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-conflict-with-limitrange-cpu
spec:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m

Response: This yaml code 1 - Limit Ranges | then that Pod will not be scheduled, failing with an error similar to:


Prompt:
Explain this text code:

Pod "example-conflict-with-limitrange-cpu" is invalid: spec.containers[0].resources.requests: Invalid value: "700m": must be less than or equal to cpu limit

Response: This text code 1 - Limit Ranges | If you set both request and limit, then that new Pod will be scheduled successfully even with the same LimitRange in place:

Context: 1 - Limit Ranges | If you set both request and limit, then that new Pod will be scheduled successfully even with the same LimitRange in place:


Prompt:
Explain this text code:

concepts/policy/limit-range/example-no-conflict-with-limitrange-cpu.yaml

Response: This text code 1 - Limit Ranges | Examples of policies that could be created using LimitRange are:

Context: 1 - Limit Ranges | Examples of policies that could be created using LimitRange are:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-no-conflict-with-limitrange-cpu
spec:
  containers:

Response:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m
      limits:
        cpu: 700m


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-no-conflict-with-limitrange-cpu
spec:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m
      limits:
        cpu: 700m

Response: This yaml code 1 - Limit Ranges | Examples of policies that could be created using LimitRange are:


Prompt:
Explain this text code:

<storage-class-name>.storageclass.storage.k8s.io/requests.storage

Response: This text code 2 - Resource Quotas | For example, if you want to quota storage with gold StorageClass separate from a bronze StorageClass, you can define a quota as follows:

Context: 2 - Resource Quotas | For example, if you want to quota storage with gold StorageClass separate from a bronze StorageClass, you can define a quota as follows:


Prompt:
Explain this text code:

<storage-class-name>.storageclass.storage.k8s.io/persistentvolumeclaims

Response: This text code 2 - Resource Quotas | For example, if you want to quota storage with gold StorageClass separate from a bronze StorageClass, you can define a quota as follows:


Prompt:
Explain this text code:

gold.storageclass.storage.k8s.io/requests.storage: 500Gi

Response: This text code 2 - Resource Quotas | When using a CRI container runtime, container logs will count against the ephemeral storage quota. This can result in the unexpected eviction of pods that have exhausted their storage quotas.

Context: 2 - Resource Quotas | When using a CRI container runtime, container logs will count against the ephemeral storage quota. This can result in the unexpected eviction of pods that have exhausted their storage quotas.


Prompt:
Explain this text code:

bronze.storageclass.storage.k8s.io/requests.storage: 100Gi

Response: This text code 2 - Resource Quotas | When using a CRI container runtime, container logs will count against the ephemeral storage quota. This can result in the unexpected eviction of pods that have exhausted their storage quotas.


Prompt:
Complete this yaml code:

scopeSelector:
    matchExpressions:
      - scopeName: PriorityClass

Response:
        operator: In
        values:
          - middle

Context: 2 - Resource Quotas | If the operator is Exists or DoesNotExist, the values field must NOT be specified.


Prompt:
Explain this yaml code:

scopeSelector:
    matchExpressions:
      - scopeName: PriorityClass
        operator: In
        values:
          - middle

Response: This yaml code 2 - Resource Quotas | If the operator is Exists or DoesNotExist, the values field must NOT be specified.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: "200Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["high"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-medium
  spec:

Response:
    hard:
      cpu: "10"
      memory: "20Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["medium"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-low
  spec:
    hard:
      cpu: "5"
      memory: "10Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["low"]

Context: 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: "200Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["high"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-medium
  spec:
    hard:
      cpu: "10"
      memory: "20Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["medium"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-low
  spec:
    hard:
      cpu: "5"
      memory: "10Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["low"]

Response: This yaml code 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Explain this text code:

resourcequota/pods-high created
resourcequota/pods-medium created
resourcequota/pods-low created

Response: This text code 2 - Resource Quotas | Verify that Used quota is 0 using kubectl describe quota.

Context: 2 - Resource Quotas | Verify that Used quota is 0 using kubectl describe quota.


Prompt:
Complete this text code:

Name:       pods-high
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     1k
memory      0     200Gi
pods        0     10

Name:       pods-low
Namespace:  default
Resource    Used  Hard

Response:
--------    ----  ----
cpu         0     5
memory      0     10Gi
pods        0     10

Name:       pods-medium
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     10
memory      0     20Gi
pods        0     10

Context: 2 - Resource Quotas | Create a pod with priority "high". Save the following YAML to a file high-priority-pod.yaml.


Prompt:
Explain this text code:

Name:       pods-high
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     1k
memory      0     200Gi
pods        0     10

Name:       pods-low
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     5
memory      0     10Gi
pods        0     10

Name:       pods-medium
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     10
memory      0     20Gi
pods        0     10

Response: This text code 2 - Resource Quotas | Create a pod with priority "high". Save the following YAML to a file high-priority-pod.yaml.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: high-priority
spec:
  containers:
  - name: high-priority
    image: ubuntu
    command: ["/bin/sh"]

Response:
    args: ["-c", "while true; do echo hello; sleep 10;done"]
    resources:
      requests:
        memory: "10Gi"
        cpu: "500m"
      limits:
        memory: "10Gi"
        cpu: "500m"
  priorityClassName: high

Context: 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: high-priority
spec:
  containers:
  - name: high-priority
    image: ubuntu
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10;done"]
    resources:
      requests:
        memory: "10Gi"
        cpu: "500m"
      limits:
        memory: "10Gi"
        cpu: "500m"
  priorityClassName: high

Response: This yaml code 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Complete this text code:

Name:       pods-high
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         500m  1k
memory      10Gi  200Gi
pods        1     10

Name:       pods-low
Namespace:  default
Resource    Used  Hard

Response:
--------    ----  ----
cpu         0     5
memory      0     10Gi
pods        0     10

Name:       pods-medium
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     10
memory      0     20Gi
pods        0     10

Context: 2 - Resource Quotas | Operators can use CrossNamespacePodAffinity quota scope to limit which namespaces are allowed to have pods with affinity terms that cross namespaces. Specifically, it controls which pods are allowed t


Prompt:
Explain this text code:

Name:       pods-high
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         500m  1k
memory      10Gi  200Gi
pods        1     10

Name:       pods-low
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     5
memory      0     10Gi
pods        0     10

Name:       pods-medium
Namespace:  default
Resource    Used  Hard
--------    ----  ----
cpu         0     10
memory      0     20Gi
pods        0     10

Response: This text code 2 - Resource Quotas | Operators can use CrossNamespacePodAffinity quota scope to limit which namespaces are allowed to have pods with affinity terms that cross namespaces. Specifically, it controls which pods are allowed t


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: disable-cross-namespace-affinity
  namespace: foo-ns
spec:

Response:
  hard:
    pods: "0"
  scopeSelector:
    matchExpressions:
    - scopeName: CrossNamespacePodAffinity
      operator: Exists

Context: 2 - Resource Quotas | If operators want to disallow using namespaces and namespaceSelector by default, and only allow it for specific namespaces, they could configure CrossNamespacePodAffinity as a limited resource by sett


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: disable-cross-namespace-affinity
  namespace: foo-ns
spec:
  hard:
    pods: "0"
  scopeSelector:
    matchExpressions:
    - scopeName: CrossNamespacePodAffinity
      operator: Exists

Response: This yaml code 2 - Resource Quotas | If operators want to disallow using namespaces and namespaceSelector by default, and only allow it for specific namespaces, they could configure CrossNamespacePodAffinity as a limited resource by sett


Prompt:
Complete this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1

Response:
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: CrossNamespacePodAffinity
        operator: Exists

Context: 2 - Resource Quotas | With the above configuration, pods can use namespaces and namespaceSelector in pod affinity only if the namespace where they are created have a resource quota object with CrossNamespacePodAffinity sco


Prompt:
Explain this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: CrossNamespacePodAffinity
        operator: Exists

Response: This yaml code 2 - Resource Quotas | With the above configuration, pods can use namespaces and namespaceSelector in pod affinity only if the namespace where they are created have a resource quota object with CrossNamespacePodAffinity sco


Prompt:
Explain this text code:

status.modifyVolumeStatus.targetVolumeAttributesClassName

Response: This text code 2 - Resource Quotas | A quota is matched and consumed only if scopeSelector in the quota spec selects the PVC.

Context: 2 - Resource Quotas | A quota is matched and consumed only if scopeSelector in the quota spec selects the PVC.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-gold
  spec:
    hard:
      requests.storage: "10Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["gold"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-silver
  spec:

Response:
    hard:
      requests.storage: "20Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["silver"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-copper
  spec:
    hard:
      requests.storage: "30Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["copper"]


Prompt:
Explain this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-gold
  spec:
    hard:
      requests.storage: "10Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["gold"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-silver
  spec:
    hard:
      requests.storage: "20Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["silver"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-copper
  spec:
    hard:
      requests.storage: "30Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["copper"]

Response: This yaml code 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Explain this text code:

resourcequota/pvcs-gold created
resourcequota/pvcs-silver created
resourcequota/pvcs-copper created

Response: This text code 2 - Resource Quotas | Verify that Used quota is 0 using kubectl describe quota.


Prompt:
Complete this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard

Response:
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     30Gi

Context: 2 - Resource Quotas | Create a pvc with volume attributes class "gold". Save the following YAML to a file gold-vac-pvc.yaml.


Prompt:
Explain this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     30Gi

Response: This text code 2 - Resource Quotas | Create a pvc with volume attributes class "gold". Save the following YAML to a file gold-vac-pvc.yaml.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:

Response:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName:  # change this to the name of the storage class you want to use
  volumeAttributesClassName: gold


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName:  # change this to the name of the storage class you want to use
  volumeAttributesClassName: gold

Response: This yaml code 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Complete this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard

Response:
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     30Gi

Context: 2 - Resource Quotas | Once the PVC is bound, it is allowed to modify the desired volume attributes class. Let's change it to "silver" with kubectl patch.


Prompt:
Explain this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     30Gi

Response: This text code 2 - Resource Quotas | Once the PVC is bound, it is allowed to modify the desired volume attributes class. Let's change it to "silver" with kubectl patch.


Prompt:
Explain this shell code:

kubectl patch pvc gold-vac-pvc --type='merge' -p '{"spec":{"volumeAttributesClassName":"silver"}}'

Response: This shell code 2 - Resource Quotas | Verify that "Used" stats for "silver" volume attributes class quota, pvcs-silver has changed, pvcs-copper is unchanged, and pvcs-gold might be unchanged or released, which depends on the PVC's status.

Context: 2 - Resource Quotas | Verify that "Used" stats for "silver" volume attributes class quota, pvcs-silver has changed, pvcs-copper is unchanged, and pvcs-gold might be unchanged or released, which depends on the PVC's status.


Prompt:
Complete this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard

Response:
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     30Gi

Context: 2 - Resource Quotas | Let's change it to "copper" with kubectl patch.


Prompt:
Explain this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     30Gi

Response: This text code 2 - Resource Quotas | Let's change it to "copper" with kubectl patch.


Prompt:
Explain this shell code:

kubectl patch pvc gold-vac-pvc --type='merge' -p '{"spec":{"volumeAttributesClassName":"copper"}}'

Response: This shell code 2 - Resource Quotas | Verify that "Used" stats for "copper" volume attributes class quota, pvcs-copper has changed, pvcs-silver and pvcs-gold might be unchanged or released, which depends on the PVC's status.

Context: 2 - Resource Quotas | Verify that "Used" stats for "copper" volume attributes class quota, pvcs-copper has changed, pvcs-silver and pvcs-gold might be unchanged or released, which depends on the PVC's status.


Prompt:
Complete this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard

Response:
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   30Gi

Context: 2 - Resource Quotas | Print the manifest of the PVC using the following command:


Prompt:
Explain this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   30Gi

Response: This text code 2 - Resource Quotas | Print the manifest of the PVC using the following command:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: default

Response:
  volumeAttributesClassName: copper
status:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 2Gi
  currentVolumeAttributesClassName: gold
  phase: Bound
  modifyVolumeStatus:
    status: InProgress
    targetVolumeAttributesClassName: silver
  storageClassName: default

Context: 2 - Resource Quotas | Wait a moment for the volume modification to complete, then verify the quota again.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: default
  volumeAttributesClassName: copper
status:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 2Gi
  currentVolumeAttributesClassName: gold
  phase: Bound
  modifyVolumeStatus:
    status: InProgress
    targetVolumeAttributesClassName: silver
  storageClassName: default

Response: This yaml code 2 - Resource Quotas | Wait a moment for the volume modification to complete, then verify the quota again.


Prompt:
Complete this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard

Response:
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   30Gi

Context: 2 - Resource Quotas | When allocating compute resources, each container may specify a request and a limit value for either CPU or memory. The quota can be configured to quota either value.


Prompt:
Explain this text code:

Name:                   pvcs-gold
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     10Gi

Name:                   pvcs-silver
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  0     10
requests.storage        0     20Gi

Name:                   pvcs-copper
Namespace:              default
Resource                Used  Hard
--------                ----  ----
persistentvolumeclaims  1     10
requests.storage        2Gi   30Gi

Response: This text code 2 - Resource Quotas | When allocating compute resources, each container may specify a request and a limit value for either CPU or memory. The quota can be configured to quota either value.


Prompt:
Complete this shell code:

cat <<EOF > compute-resources.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-resources
spec:

Response:
  hard:
    requests.cpu: "1"
    requests.memory: "1Gi"
    limits.cpu: "2"
    limits.memory: "2Gi"
    requests.nvidia.com/gpu: 4
EOF

Context: 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this shell code:

cat <<EOF > compute-resources.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-resources
spec:
  hard:
    requests.cpu: "1"
    requests.memory: "1Gi"
    limits.cpu: "2"
    limits.memory: "2Gi"
    requests.nvidia.com/gpu: 4
EOF

Response: This shell code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this shell code:

kubectl create -f ./compute-resources.yaml --namespace=myspace

Response: This shell code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Complete this shell code:

cat <<EOF > object-counts.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-counts
spec:
  hard:

Response:
    configmaps: "10"
    persistentvolumeclaims: "4"
    pods: "4"
    replicationcontrollers: "20"
    secrets: "10"
    services: "10"
    services.loadbalancers: "2"
EOF


Prompt:
Explain this shell code:

cat <<EOF > object-counts.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-counts
spec:
  hard:
    configmaps: "10"
    persistentvolumeclaims: "4"
    pods: "4"
    replicationcontrollers: "20"
    secrets: "10"
    services: "10"
    services.loadbalancers: "2"
EOF

Response: This shell code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this shell code:

kubectl create -f ./object-counts.yaml --namespace=myspace

Response: This shell code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this none code:

NAME                    AGE
compute-resources       30s
object-counts           32s

Response: This none code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this shell code:

kubectl describe quota compute-resources --namespace=myspace

Response: This shell code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Complete this none code:

Name:                    compute-resources
Namespace:               myspace
Resource                 Used  Hard
--------                 ----  ----

Response:
limits.cpu               0     2
limits.memory            0     2Gi
requests.cpu             0     1
requests.memory          0     1Gi
requests.nvidia.com/gpu  0     4


Prompt:
Explain this none code:

Name:                    compute-resources
Namespace:               myspace
Resource                 Used  Hard
--------                 ----  ----
limits.cpu               0     2
limits.memory            0     2Gi
requests.cpu             0     1
requests.memory          0     1Gi
requests.nvidia.com/gpu  0     4

Response: This none code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this shell code:

kubectl describe quota object-counts --namespace=myspace

Response: This shell code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Complete this none code:

Name:                   object-counts
Namespace:              myspace
Resource                Used    Hard
--------                ----    ----
configmaps              0       10

Response:
persistentvolumeclaims  0       4
pods                    0       4
replicationcontrollers  0       20
secrets                 1       10
services                0       10
services.loadbalancers  0       2


Prompt:
Explain this none code:

Name:                   object-counts
Namespace:              myspace
Resource                Used    Hard
--------                ----    ----
configmaps              0       10
persistentvolumeclaims  0       4
pods                    0       4
replicationcontrollers  0       20
secrets                 1       10
services                0       10
services.loadbalancers  0       2

Response: This none code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this shell code:

kubectl create quota test --hard=count/deployments.apps=2,count/replicasets.apps=4,count/pods=3,count/secrets=4 --namespace=myspace

Response: This shell code 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu

Context: 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu


Prompt:
Explain this shell code:

kubectl create deployment nginx --image=nginx --namespace=myspace --replicas=2

Response: This shell code 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu


Prompt:
Complete this text code:

Name:                         test
Namespace:                    myspace
Resource                      Used  Hard
--------                      ----  ----

Response:
count/deployments.apps        1     2
count/pods                    2     3
count/replicasets.apps        1     4
count/secrets                 1     4


Prompt:
Explain this text code:

Name:                         test
Namespace:                    myspace
Resource                      Used  Hard
--------                      ----  ----
count/deployments.apps        1     2
count/pods                    2     3
count/replicasets.apps        1     4
count/secrets                 1     4

Response: This text code 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu


Prompt:
Complete this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1

Response:
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: PriorityClass
        operator: In
        values: ["cluster-services"]

Context: 2 - Resource Quotas | Then, create a resource quota object in the kube-system namespace:


Prompt:
Explain this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: PriorityClass
        operator: In
        values: ["cluster-services"]

Response: This yaml code 2 - Resource Quotas | Then, create a resource quota object in the kube-system namespace:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-cluster-services
spec:

Response:
  scopeSelector:
    matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["cluster-services"]

Context: 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-cluster-services
spec:
  scopeSelector:
    matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["cluster-services"]

Response: This yaml code 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/policy/priority-class-resourcequota.yaml -n kube-system

Response: This shell code 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Complete this yaml code:

spec:
  containers:

Response:
  - name: nginx
    image: nginx

Context: 4 - Node Resource Managers | The pod above runs in the BestEffort QoS class because no resource requests or limits are specified. It runs in the shared pool.


Prompt:
Explain this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx

Response: This yaml code 4 - Node Resource Managers | The pod above runs in the BestEffort QoS class because no resource requests or limits are specified. It runs in the shared pool.


Prompt:
Complete this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx

Response:
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"

Context: 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits and the cpu quantity is not specified. It runs in the shared pool.


Prompt:
Explain this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"

Response: This yaml code 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits and the cpu quantity is not specified. It runs in the shared pool.


Prompt:
Complete this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:

Response:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "100Mi"
        cpu: "1"

Context: 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits. It runs in the shared pool.


Prompt:
Explain this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "100Mi"
        cpu: "1"

Response: This yaml code 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits. It runs in the shared pool.


Prompt:
Complete this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:

Response:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "200Mi"
        cpu: "2"

Context: 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. And the container's resource limit for the CPU resource is an integer greater than or equal to one. The nginx conta


Prompt:
Explain this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "200Mi"
        cpu: "2"

Response: This yaml code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. And the container's resource limit for the CPU resource is an integer greater than or equal to one. The nginx conta


Prompt:
Complete this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:

Response:
      limits:
        memory: "200Mi"
        cpu: "1.5"
      requests:
        memory: "200Mi"
        cpu: "1.5"

Context: 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. But the container's resource limit for the CPU resource is a fraction. It runs in the shared pool.


Prompt:
Explain this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "1.5"
      requests:
        memory: "200Mi"
        cpu: "1.5"

Response: This yaml code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. But the container's resource limit for the CPU resource is a fraction. It runs in the shared pool.


Prompt:
Complete this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx

Response:
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"

Context: 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because only limits are specified and requests are set equal to limits when not explicitly specified. And the container's resource limit for the CPU reso


Prompt:
Explain this yaml code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"

Response: This yaml code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because only limits are specified and requests are set equal to limits when not explicitly specified. And the container's resource limit for the CPU reso


Prompt:
Complete this yaml code:

concepts/policy/limit-range/problematic-limit-range.yaml
apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-resource-constraint
spec:
  limits:
  - default: # this section defines default limits

Response:
      cpu: 500m
    defaultRequest: # this section defines default requests
      cpu: 500m
    max: # max and min define the limit range
      cpu: "1"
    min:
      cpu: 100m
    type: Container

Context: 1 - Limit Ranges | along with a Pod that declares a CPU resource request of 700m, but not a limit:


Prompt:
Explain this yaml code:

concepts/policy/limit-range/problematic-limit-range.yaml
apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-resource-constraint
spec:
  limits:
  - default: # this section defines default limits
      cpu: 500m
    defaultRequest: # this section defines default requests
      cpu: 500m
    max: # max and min define the limit range
      cpu: "1"
    min:
      cpu: 100m
    type: Container

Response: This yaml code 1 - Limit Ranges | along with a Pod that declares a CPU resource request of 700m, but not a limit:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-resource-constraint
spec:
  limits:
  - default: # this section defines default limits

Response:
      cpu: 500m
    defaultRequest: # this section defines default requests
      cpu: 500m
    max: # max and min define the limit range
      cpu: "1"
    min:
      cpu: 100m
    type: Container


Prompt:
Explain this yaml code:

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-resource-constraint
spec:
  limits:
  - default: # this section defines default limits
      cpu: 500m
    defaultRequest: # this section defines default requests
      cpu: 500m
    max: # max and min define the limit range
      cpu: "1"
    min:
      cpu: 100m
    type: Container

Response: This yaml code 1 - Limit Ranges | along with a Pod that declares a CPU resource request of 700m, but not a limit:


Prompt:
Complete this yaml code:

concepts/policy/limit-range/example-conflict-with-limitrange-cpu.yaml
apiVersion: v1
kind: Pod
metadata:
  name: example-conflict-with-limitrange-cpu
spec:

Response:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m

Context: 1 - Limit Ranges | then that Pod will not be scheduled, failing with an error similar to:


Prompt:
Explain this yaml code:

concepts/policy/limit-range/example-conflict-with-limitrange-cpu.yaml
apiVersion: v1
kind: Pod
metadata:
  name: example-conflict-with-limitrange-cpu
spec:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m

Response: This yaml code 1 - Limit Ranges | then that Pod will not be scheduled, failing with an error similar to:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-conflict-with-limitrange-cpu
spec:

Response:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-conflict-with-limitrange-cpu
spec:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m

Response: This yaml code 1 - Limit Ranges | then that Pod will not be scheduled, failing with an error similar to:


Prompt:
Complete this yaml code:

concepts/policy/limit-range/example-no-conflict-with-limitrange-cpu.yaml
apiVersion: v1
kind: Pod
metadata:
  name: example-no-conflict-with-limitrange-cpu
spec:
  containers:

Response:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m
      limits:
        cpu: 700m

Context: 1 - Limit Ranges | Examples of policies that could be created using LimitRange are:


Prompt:
Explain this yaml code:

concepts/policy/limit-range/example-no-conflict-with-limitrange-cpu.yaml
apiVersion: v1
kind: Pod
metadata:
  name: example-no-conflict-with-limitrange-cpu
spec:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m
      limits:
        cpu: 700m

Response: This yaml code 1 - Limit Ranges | Examples of policies that could be created using LimitRange are:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-no-conflict-with-limitrange-cpu
spec:
  containers:

Response:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m
      limits:
        cpu: 700m


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-no-conflict-with-limitrange-cpu
spec:
  containers:
  - name: demo
    image: registry.k8s.io/pause:3.8
    resources:
      requests:
        cpu: 700m
      limits:
        cpu: 700m

Response: This yaml code 1 - Limit Ranges | Examples of policies that could be created using LimitRange are:


Prompt:
Complete this text code:

scopeSelector:
    matchExpressions:
      - scopeName: PriorityClass

Response:
        operator: In
        values:
          - middle

Context: 2 - Resource Quotas | If the operator is Exists or DoesNotExist, the values field must NOT be specified.


Prompt:
Explain this text code:

scopeSelector:
    matchExpressions:
      - scopeName: PriorityClass
        operator: In
        values:
          - middle

Response: This text code 2 - Resource Quotas | If the operator is Exists or DoesNotExist, the values field must NOT be specified.


Prompt:
Complete this yaml code:

policy/quota.yaml
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: "200Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["high"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-medium
  spec:

Response:
    hard:
      cpu: "10"
      memory: "20Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["medium"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-low
  spec:
    hard:
      cpu: "5"
      memory: "10Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["low"]

Context: 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Explain this yaml code:

policy/quota.yaml
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: "200Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["high"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-medium
  spec:
    hard:
      cpu: "10"
      memory: "20Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["medium"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-low
  spec:
    hard:
      cpu: "5"
      memory: "10Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["low"]

Response: This yaml code 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: "200Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["high"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-medium
  spec:

Response:
    hard:
      cpu: "10"
      memory: "20Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["medium"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-low
  spec:
    hard:
      cpu: "5"
      memory: "10Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["low"]


Prompt:
Explain this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: "200Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["high"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-medium
  spec:
    hard:
      cpu: "10"
      memory: "20Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["medium"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-low
  spec:
    hard:
      cpu: "5"
      memory: "10Gi"
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: PriorityClass
        values: ["low"]

Response: This yaml code 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Complete this yaml code:

policy/high-priority-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: high-priority
spec:
  containers:
  - name: high-priority
    image: ubuntu

Response:
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10;done"]
    resources:
      requests:
        memory: "10Gi"
        cpu: "500m"
      limits:
        memory: "10Gi"
        cpu: "500m"
  priorityClassName: high

Context: 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Explain this yaml code:

policy/high-priority-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: high-priority
spec:
  containers:
  - name: high-priority
    image: ubuntu
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10;done"]
    resources:
      requests:
        memory: "10Gi"
        cpu: "500m"
      limits:
        memory: "10Gi"
        cpu: "500m"
  priorityClassName: high

Response: This yaml code 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: high-priority
spec:
  containers:
  - name: high-priority
    image: ubuntu
    command: ["/bin/sh"]

Response:
    args: ["-c", "while true; do echo hello; sleep 10;done"]
    resources:
      requests:
        memory: "10Gi"
        cpu: "500m"
      limits:
        memory: "10Gi"
        cpu: "500m"
  priorityClassName: high


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: high-priority
spec:
  containers:
  - name: high-priority
    image: ubuntu
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10;done"]
    resources:
      requests:
        memory: "10Gi"
        cpu: "500m"
      limits:
        memory: "10Gi"
        cpu: "500m"
  priorityClassName: high

Response: This yaml code 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: disable-cross-namespace-affinity
  namespace: foo-ns
spec:

Response:
  hard:
    pods: "0"
  scopeSelector:
    matchExpressions:
    - scopeName: CrossNamespacePodAffinity
      operator: Exists

Context: 2 - Resource Quotas | If operators want to disallow using namespaces and namespaceSelector by default, and only allow it for specific namespaces, they could configure CrossNamespacePodAffinity as a limited resource by sett


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: disable-cross-namespace-affinity
  namespace: foo-ns
spec:
  hard:
    pods: "0"
  scopeSelector:
    matchExpressions:
    - scopeName: CrossNamespacePodAffinity
      operator: Exists

Response: This yaml code 2 - Resource Quotas | If operators want to disallow using namespaces and namespaceSelector by default, and only allow it for specific namespaces, they could configure CrossNamespacePodAffinity as a limited resource by sett


Prompt:
Complete this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1

Response:
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: CrossNamespacePodAffinity
        operator: Exists

Context: 2 - Resource Quotas | With the above configuration, pods can use namespaces and namespaceSelector in pod affinity only if the namespace where they are created have a resource quota object with CrossNamespacePodAffinity sco


Prompt:
Explain this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: CrossNamespacePodAffinity
        operator: Exists

Response: This yaml code 2 - Resource Quotas | With the above configuration, pods can use namespaces and namespaceSelector in pod affinity only if the namespace where they are created have a resource quota object with CrossNamespacePodAffinity sco


Prompt:
Complete this yaml code:

policy/quota-vac.yaml
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-gold
  spec:
    hard:
      requests.storage: "10Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["gold"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-silver

Response:
  spec:
    hard:
      requests.storage: "20Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["silver"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-copper
  spec:
    hard:
      requests.storage: "30Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["copper"]


Prompt:
Explain this yaml code:

policy/quota-vac.yaml
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-gold
  spec:
    hard:
      requests.storage: "10Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["gold"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-silver
  spec:
    hard:
      requests.storage: "20Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["silver"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-copper
  spec:
    hard:
      requests.storage: "30Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["copper"]

Response: This yaml code 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-gold
  spec:
    hard:
      requests.storage: "10Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["gold"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-silver
  spec:

Response:
    hard:
      requests.storage: "20Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["silver"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-copper
  spec:
    hard:
      requests.storage: "30Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["copper"]


Prompt:
Explain this yaml code:

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-gold
  spec:
    hard:
      requests.storage: "10Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["gold"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-silver
  spec:
    hard:
      requests.storage: "20Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["silver"]
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pvcs-copper
  spec:
    hard:
      requests.storage: "30Gi"
      persistentvolumeclaims: "10"
    scopeSelector:
      matchExpressions:
      - operator: In
        scopeName: VolumeAttributesClass
        values: ["copper"]

Response: This yaml code 2 - Resource Quotas | Apply the YAML using kubectl create.


Prompt:
Complete this yaml code:

policy/gold-vac-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:

Response:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName:  # change this to the name of the storage class you want to use
  volumeAttributesClassName: gold


Prompt:
Explain this yaml code:

policy/gold-vac-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName:  # change this to the name of the storage class you want to use
  volumeAttributesClassName: gold

Response: This yaml code 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:

Response:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName:  # change this to the name of the storage class you want to use
  volumeAttributesClassName: gold


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName:  # change this to the name of the storage class you want to use
  volumeAttributesClassName: gold

Response: This yaml code 2 - Resource Quotas | Apply it with kubectl create.


Prompt:
Explain this bash code:

kubectl patch pvc gold-vac-pvc --type='merge' -p '{"spec":{"volumeAttributesClassName":"silver"}}'

Response: This bash code 2 - Resource Quotas | Verify that "Used" stats for "silver" volume attributes class quota, pvcs-silver has changed, pvcs-copper is unchanged, and pvcs-gold might be unchanged or released, which depends on the PVC's status.

Context: 2 - Resource Quotas | Verify that "Used" stats for "silver" volume attributes class quota, pvcs-silver has changed, pvcs-copper is unchanged, and pvcs-gold might be unchanged or released, which depends on the PVC's status.


Prompt:
Explain this bash code:

kubectl patch pvc gold-vac-pvc --type='merge' -p '{"spec":{"volumeAttributesClassName":"copper"}}'

Response: This bash code 2 - Resource Quotas | Verify that "Used" stats for "copper" volume attributes class quota, pvcs-copper has changed, pvcs-silver and pvcs-gold might be unchanged or released, which depends on the PVC's status.

Context: 2 - Resource Quotas | Verify that "Used" stats for "copper" volume attributes class quota, pvcs-copper has changed, pvcs-silver and pvcs-gold might be unchanged or released, which depends on the PVC's status.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: default

Response:
  volumeAttributesClassName: copper
status:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 2Gi
  currentVolumeAttributesClassName: gold
  phase: Bound
  modifyVolumeStatus:
    status: InProgress
    targetVolumeAttributesClassName: silver
  storageClassName: default

Context: 2 - Resource Quotas | Wait a moment for the volume modification to complete, then verify the quota again.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gold-vac-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: default
  volumeAttributesClassName: copper
status:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 2Gi
  currentVolumeAttributesClassName: gold
  phase: Bound
  modifyVolumeStatus:
    status: InProgress
    targetVolumeAttributesClassName: silver
  storageClassName: default

Response: This yaml code 2 - Resource Quotas | Wait a moment for the volume modification to complete, then verify the quota again.


Prompt:
Complete this yaml code:

cat <<EOF > compute-resources.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-resources
spec:

Response:
  hard:
    requests.cpu: "1"
    requests.memory: "1Gi"
    limits.cpu: "2"
    limits.memory: "2Gi"
    requests.nvidia.com/gpu: 4
EOF

Context: 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this yaml code:

cat <<EOF > compute-resources.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-resources
spec:
  hard:
    requests.cpu: "1"
    requests.memory: "1Gi"
    limits.cpu: "2"
    limits.memory: "2Gi"
    requests.nvidia.com/gpu: 4
EOF

Response: This yaml code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this bash code:

kubectl create -f ./compute-resources.yaml --namespace=myspace

Response: This bash code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Complete this yaml code:

cat <<EOF > object-counts.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-counts
spec:
  hard:

Response:
    configmaps: "10"
    persistentvolumeclaims: "4"
    pods: "4"
    replicationcontrollers: "20"
    secrets: "10"
    services: "10"
    services.loadbalancers: "2"
EOF


Prompt:
Explain this yaml code:

cat <<EOF > object-counts.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-counts
spec:
  hard:
    configmaps: "10"
    persistentvolumeclaims: "4"
    pods: "4"
    replicationcontrollers: "20"
    secrets: "10"
    services: "10"
    services.loadbalancers: "2"
EOF

Response: This yaml code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this bash code:

kubectl create -f ./object-counts.yaml --namespace=myspace

Response: This bash code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this bash code:

kubectl describe quota compute-resources --namespace=myspace

Response: This bash code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this bash code:

kubectl describe quota object-counts --namespace=myspace

Response: This bash code 2 - Resource Quotas | kubectl also supports object count quota for all standard namespaced resources using the syntax count/<resource>.<group>:


Prompt:
Explain this bash code:

kubectl create quota test --hard=count/deployments.apps=2,count/replicasets.apps=4,count/pods=3,count/secrets=4 --namespace=myspace

Response: This bash code 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu

Context: 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu


Prompt:
Explain this bash code:

kubectl create deployment nginx --image=nginx --namespace=myspace --replicas=2

Response: This bash code 2 - Resource Quotas | ResourceQuotas are independent of the cluster capacity. They are expressed in absolute units. So, if you add nodes to your cluster, this does not automatically give each namespace the ability to consu


Prompt:
Complete this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1

Response:
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: PriorityClass
        operator: In
        values: ["cluster-services"]

Context: 2 - Resource Quotas | Then, create a resource quota object in the kube-system namespace:


Prompt:
Explain this yaml code:

apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: "ResourceQuota"
  configuration:
    apiVersion: apiserver.config.k8s.io/v1
    kind: ResourceQuotaConfiguration
    limitedResources:
    - resource: pods
      matchScopes:
      - scopeName: PriorityClass
        operator: In
        values: ["cluster-services"]

Response: This yaml code 2 - Resource Quotas | Then, create a resource quota object in the kube-system namespace:


Prompt:
Complete this yaml code:

policy/priority-class-resourcequota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-cluster-services

Response:
spec:
  scopeSelector:
    matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["cluster-services"]

Context: 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Explain this yaml code:

policy/priority-class-resourcequota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-cluster-services
spec:
  scopeSelector:
    matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["cluster-services"]

Response: This yaml code 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-cluster-services
spec:

Response:
  scopeSelector:
    matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["cluster-services"]


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-cluster-services
spec:
  scopeSelector:
    matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["cluster-services"]

Response: This yaml code 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/policy/priority-class-resourcequota.yaml -n kube-system

Response: This bash code 2 - Resource Quotas | In this case, a pod creation will be allowed if:


Prompt:
Complete this text code:

spec:
  containers:

Response:
  - name: nginx
    image: nginx

Context: 4 - Node Resource Managers | The pod above runs in the BestEffort QoS class because no resource requests or limits are specified. It runs in the shared pool.


Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx

Response: This text code 4 - Node Resource Managers | The pod above runs in the BestEffort QoS class because no resource requests or limits are specified. It runs in the shared pool.


Prompt:
Complete this text code:

spec:
  containers:
  - name: nginx
    image: nginx

Response:
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"

Context: 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits and the cpu quantity is not specified. It runs in the shared pool.


Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"

Response: This text code 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits and the cpu quantity is not specified. It runs in the shared pool.


Prompt:
Complete this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:

Response:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "100Mi"
        cpu: "1"

Context: 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits. It runs in the shared pool.


Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "100Mi"
        cpu: "1"

Response: This text code 4 - Node Resource Managers | The pod above runs in the Burstable QoS class because resource requests do not equal limits. It runs in the shared pool.


Prompt:
Complete this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:

Response:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "200Mi"
        cpu: "2"

Context: 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. And the container's resource limit for the CPU resource is an integer greater than or equal to one. The nginx conta


Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "200Mi"
        cpu: "2"

Response: This text code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. And the container's resource limit for the CPU resource is an integer greater than or equal to one. The nginx conta


Prompt:
Complete this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:

Response:
      limits:
        memory: "200Mi"
        cpu: "1.5"
      requests:
        memory: "200Mi"
        cpu: "1.5"

Context: 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. But the container's resource limit for the CPU resource is a fraction. It runs in the shared pool.


Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "1.5"
      requests:
        memory: "200Mi"
        cpu: "1.5"

Response: This text code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because requests are equal to limits. But the container's resource limit for the CPU resource is a fraction. It runs in the shared pool.


Prompt:
Complete this text code:

spec:
  containers:
  - name: nginx
    image: nginx

Response:
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"

Context: 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because only limits are specified and requests are set equal to limits when not explicitly specified. And the container's resource limit for the CPU reso


Prompt:
Explain this text code:

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"

Response: This text code 4 - Node Resource Managers | The pod above runs in the Guaranteed QoS class because only limits are specified and requests are set equal to limits when not explicitly specified. And the container's resource limit for the CPU reso


Prompt:
Explain this bash code:

kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none]

Response: This bash code kubectl create rolebinding | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.

Context: kubectl create rolebinding | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Complete this text code:

# Create a role binding for user1, user2, and group1 using the admin cluster role
  kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1

Response:
  # Create a role binding for service account monitoring:sa-dev using the admin role
  kubectl create rolebinding admin-binding --role=admin --serviceaccount=monitoring:sa-dev


Prompt:
Explain this text code:

# Create a role binding for user1, user2, and group1 using the admin cluster role
  kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1

  # Create a role binding for service account monitoring:sa-dev using the admin role
  kubectl create rolebinding admin-binding --role=admin --serviceaccount=monitoring:sa-dev

Response: This text code kubectl create rolebinding | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Explain this bash code:

kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none]

Response: This bash code kubectl create rolebinding | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Complete this text code:

# Create a role binding for user1, user2, and group1 using the admin cluster role
  kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1

Response:
  # Create a role binding for service account monitoring:sa-dev using the admin role
  kubectl create rolebinding admin-binding --role=admin --serviceaccount=monitoring:sa-dev


Prompt:
Explain this text code:

# Create a role binding for user1, user2, and group1 using the admin cluster role
  kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1

  # Create a role binding for service account monitoring:sa-dev using the admin role
  kubectl create rolebinding admin-binding --role=admin --serviceaccount=monitoring:sa-dev

Response: This text code kubectl create rolebinding | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Complete this text code:

# Create a pod using the data in pod.json
  kubectl create -f ./pod.json

  # Create a pod based on the JSON passed into stdin

Response:
  cat pod.json | kubectl create -f -

  # Edit the data in registry.yaml in JSON then create the resource using the edited data
  kubectl create -f registry.yaml --edit -o json

Context: kubectl create | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Explain this text code:

# Create a pod using the data in pod.json
  kubectl create -f ./pod.json

  # Create a pod based on the JSON passed into stdin
  cat pod.json | kubectl create -f -

  # Edit the data in registry.yaml in JSON then create the resource using the edited data
  kubectl create -f registry.yaml --edit -o json

Response: This text code kubectl create | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Complete this text code:

# Create a pod using the data in pod.json
  kubectl create -f ./pod.json

  # Create a pod based on the JSON passed into stdin

Response:
  cat pod.json | kubectl create -f -

  # Edit the data in registry.yaml in JSON then create the resource using the edited data
  kubectl create -f registry.yaml --edit -o json


Prompt:
Explain this text code:

# Create a pod using the data in pod.json
  kubectl create -f ./pod.json

  # Create a pod based on the JSON passed into stdin
  cat pod.json | kubectl create -f -

  # Edit the data in registry.yaml in JSON then create the resource using the edited data
  kubectl create -f registry.yaml --edit -o json

Response: This text code kubectl create | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.


Prompt:
Complete this text code:

# Rollback to the previous deployment
  kubectl rollout undo deployment/abc

  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

Response:
  # Restart a deployment
  kubectl rollout restart deployment/abc

  # Restart deployments with the 'app=nginx' label
  kubectl rollout restart deployment --selector=app=nginx

Context: kubectl rollout | help for rollout


Prompt:
Explain this text code:

# Rollback to the previous deployment
  kubectl rollout undo deployment/abc

  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

  # Restart a deployment
  kubectl rollout restart deployment/abc

  # Restart deployments with the 'app=nginx' label
  kubectl rollout restart deployment --selector=app=nginx

Response: This text code kubectl rollout | help for rollout

Context: kubectl rollout | help for rollout


Prompt:
Complete this text code:

# Rollback to the previous deployment
  kubectl rollout undo deployment/abc

  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

Response:
  # Restart a deployment
  kubectl rollout restart deployment/abc

  # Restart deployments with the 'app=nginx' label
  kubectl rollout restart deployment --selector=app=nginx

Context: kubectl rollout | help for rollout


Prompt:
Explain this text code:

# Rollback to the previous deployment
  kubectl rollout undo deployment/abc

  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

  # Restart a deployment
  kubectl rollout restart deployment/abc

  # Restart deployments with the 'app=nginx' label
  kubectl rollout restart deployment --selector=app=nginx

Response: This text code kubectl rollout | help for rollout

Context: kubectl rollout | help for rollout


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command

Response:
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure

Context: Define a Command and Arguments for a Container | Create a Pod based on the YAML configuration file:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure

Response: This yaml code Define a Command and Arguments for a Container | Create a Pod based on the YAML configuration file:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/pods/commands.yaml

Response: This bash code Define a Command and Arguments for a Container | List the running Pods:

Context: Define a Command and Arguments for a Container | List the running Pods:


Prompt:
Complete this text code:

env:
- name: MESSAGE

Response:
  value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]

Context: Define a Command and Arguments for a Container | This means you can define an argument for a Pod using any of the techniques available for defining environment variables, including ConfigMaps and Secrets.


Prompt:
Explain this text code:

env:
- name: MESSAGE
  value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]

Response: This text code Define a Command and Arguments for a Container | This means you can define an argument for a Pod using any of the techniques available for defining environment variables, including ConfigMaps and Secrets.


Prompt:
Explain this text code:

command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]

Response: This text code Define a Command and Arguments for a Container |

Context: Define a Command and Arguments for a Container |


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command

Response:
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure

Response: This yaml code Define a Command and Arguments for a Container | Create a Pod based on the YAML configuration file:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/pods/commands.yaml

Response: This shell code Define a Command and Arguments for a Container | List the running Pods:


Prompt:
Complete this yaml code:

env:
- name: MESSAGE

Response:
  value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]


Prompt:
Explain this yaml code:

env:
- name: MESSAGE
  value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]

Response: This yaml code Define a Command and Arguments for a Container | This means you can define an argument for a Pod using any of the techniques available for defining environment variables, including ConfigMaps and Secrets.


Prompt:
Explain this shell code:

command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]

Response: This shell code Define a Command and Arguments for a Container |


Prompt:
Complete this yaml code:

pods/commands.yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command

Response:
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure


Prompt:
Explain this yaml code:

pods/commands.yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure

Response: This yaml code Define a Command and Arguments for a Container | Create a Pod based on the YAML configuration file:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command

Response:
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
  restartPolicy: OnFailure

Response: This yaml code Define a Command and Arguments for a Container | Create a Pod based on the YAML configuration file:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/pods/commands.yaml

Response: This bash code Define a Command and Arguments for a Container | List the running Pods:


Prompt:
Complete this text code:

env:
- name: MESSAGE

Response:
  value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]


Prompt:
Explain this text code:

env:
- name: MESSAGE
  value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]

Response: This text code Define a Command and Arguments for a Container | This means you can define an argument for a Pod using any of the techniques available for defining environment variables, including ConfigMaps and Secrets.


Prompt:
Explain this text code:

command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]

Response: This text code Define a Command and Arguments for a Container |


Prompt:
Complete this text code:

daemonsets "<daemonset-name>"
REVISION        CHANGE-CAUSE

Response:
1               ...
2               ...
...

Context: Perform a Rollback on a DaemonSet | To see the details of a specific revision:


Prompt:
Explain this text code:

daemonsets "<daemonset-name>"
REVISION        CHANGE-CAUSE
1               ...
2               ...
...

Response: This text code Perform a Rollback on a DaemonSet | To see the details of a specific revision:


Prompt:
Explain this bash code:

kubectl rollout history daemonset <daemonset-name> --revision=1

Response: This bash code Perform a Rollback on a DaemonSet | This returns the details of that revision:

Context: Perform a Rollback on a DaemonSet | This returns the details of that revision:


Prompt:
Complete this text code:

daemonsets "<daemonset-name>" with revision #1
Pod Template:
Labels:       foo=bar
Containers:
app:

Response:
 Image:        ...
 Port:         ...
 Environment:  ...
 Mounts:       ...
Volumes:      ...

Context: Perform a Rollback on a DaemonSet | If it succeeds, the command returns:


Prompt:
Explain this text code:

daemonsets "<daemonset-name>" with revision #1
Pod Template:
Labels:       foo=bar
Containers:
app:
 Image:        ...
 Port:         ...
 Environment:  ...
 Mounts:       ...
Volumes:      ...

Response: This text code Perform a Rollback on a DaemonSet | If it succeeds, the command returns:


Prompt:
Explain this text code:

# Specify the revision number you get from Step 1 in --to-revision
kubectl rollout undo daemonset <daemonset-name> --to-revision=<revision>

Response: This text code Perform a Rollback on a DaemonSet | If it succeeds, the command returns:


Prompt:
Explain this text code:

daemonset "<daemonset-name>" successfully rolled out

Response: This text code Perform a Rollback on a DaemonSet | In the previous kubectl rollout history step, you got a list of DaemonSet revisions. Each revision is stored in a resource named ControllerRevision.

Context: Perform a Rollback on a DaemonSet | In the previous kubectl rollout history step, you got a list of DaemonSet revisions. Each revision is stored in a resource named ControllerRevision.


Prompt:
Explain this bash code:

kubectl get controllerrevision -l <daemonset-selector-key>=<daemonset-selector-value>

Response: This bash code Perform a Rollback on a DaemonSet | This returns a list of ControllerRevisions:

Context: Perform a Rollback on a DaemonSet | This returns a list of ControllerRevisions:


Prompt:
Explain this text code:

NAME                               CONTROLLER                     REVISION   AGE
<daemonset-name>-<revision-hash>   DaemonSet/<daemonset-name>     1          1h
<daemonset-name>-<revision-hash>   DaemonSet/<daemonset-name>     2          1h

Response: This text code Perform a Rollback on a DaemonSet | Each ControllerRevision stores the annotations and template of a DaemonSet revision.

Context: Perform a Rollback on a DaemonSet | Each ControllerRevision stores the annotations and template of a DaemonSet revision.


Prompt:
Complete this text code:

daemonsets "<daemonset-name>"
REVISION        CHANGE-CAUSE

Response:
1               ...
2               ...
...


Prompt:
Explain this text code:

daemonsets "<daemonset-name>"
REVISION        CHANGE-CAUSE
1               ...
2               ...
...

Response: This text code Perform a Rollback on a DaemonSet | To see the details of a specific revision:


Prompt:
Explain this shell code:

kubectl rollout history daemonset <daemonset-name> --revision=1

Response: This shell code Perform a Rollback on a DaemonSet | This returns the details of that revision:


Prompt:
Complete this text code:

daemonsets "<daemonset-name>" with revision #1
Pod Template:
Labels:       foo=bar
Containers:
app:

Response:
 Image:        ...
 Port:         ...
 Environment:  ...
 Mounts:       ...
Volumes:      ...


Prompt:
Explain this text code:

daemonsets "<daemonset-name>" with revision #1
Pod Template:
Labels:       foo=bar
Containers:
app:
 Image:        ...
 Port:         ...
 Environment:  ...
 Mounts:       ...
Volumes:      ...

Response: This text code Perform a Rollback on a DaemonSet | If it succeeds, the command returns:


Prompt:
Explain this shell code:

# Specify the revision number you get from Step 1 in --to-revision
kubectl rollout undo daemonset <daemonset-name> --to-revision=<revision>

Response: This shell code Perform a Rollback on a DaemonSet | If it succeeds, the command returns:


Prompt:
Explain this text code:

daemonset "<daemonset-name>" successfully rolled out

Response: This text code Perform a Rollback on a DaemonSet | In the previous kubectl rollout history step, you got a list of DaemonSet revisions. Each revision is stored in a resource named ControllerRevision.


Prompt:
Explain this shell code:

kubectl get controllerrevision -l <daemonset-selector-key>=<daemonset-selector-value>

Response: This shell code Perform a Rollback on a DaemonSet | This returns a list of ControllerRevisions:


Prompt:
Explain this text code:

NAME                               CONTROLLER                     REVISION   AGE
<daemonset-name>-<revision-hash>   DaemonSet/<daemonset-name>     1          1h
<daemonset-name>-<revision-hash>   DaemonSet/<daemonset-name>     2          1h

Response: This text code Perform a Rollback on a DaemonSet | Each ControllerRevision stores the annotations and template of a DaemonSet revision.


Prompt:
Explain this bash code:

kubectl rollout history daemonset <daemonset-name> --revision=1

Response: This bash code Perform a Rollback on a DaemonSet | This returns the details of that revision:


Prompt:
Explain this text code:

# Specify the revision number you get from Step 1 in --to-revision
kubectl rollout undo daemonset <daemonset-name> --to-revision=<revision>

Response: This text code Perform a Rollback on a DaemonSet | If it succeeds, the command returns:


Prompt:
Explain this bash code:

kubectl get controllerrevision -l <daemonset-selector-key>=<daemonset-selector-value>

Response: This bash code Perform a Rollback on a DaemonSet | This returns a list of ControllerRevisions:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure

Response:
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU

Context: Schedule GPUs | If different nodes in your cluster have different types of GPUs, then you can use Node Labels and Node Selectors to schedule pods to appropriate nodes.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU

Response: This yaml code Schedule GPUs | If different nodes in your cluster have different types of GPUs, then you can use Node Labels and Node Selectors to schedule pods to appropriate nodes.


Prompt:
Explain this text code:

# Label your nodes with the accelerator type they have.
kubectl label nodes node1 accelerator=example-gpu-x100
kubectl label nodes node2 accelerator=other-gpu-k915

Response: This text code Schedule GPUs | That label key accelerator is just an example; you can use a different label key if you prefer.

Context: Schedule GPUs | That label key accelerator is just an example; you can use a different label key if you prefer.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure
  # You can use Kubernetes node affinity to schedule this Pod onto a node
  # that provides the kind of GPU that its container needs in order to work
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:

Response:
        - matchExpressions:
          - key: "gpu.gpu-vendor.example/installed-memory"
            operator: Gt # (greater than)
            values: ["40535"]
          - key: "feature.node.kubernetes.io/pci-10.present" # NFD Feature label
            values: ["true"] # (optional) only schedule on nodes with PCI device 10
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU

Context: Schedule GPUs | Items on this page refer to third party products or projects that provide functionality required by Kubernetes. The Kubernetes project authors aren't responsible for those third-party products or proj


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure
  # You can use Kubernetes node affinity to schedule this Pod onto a node
  # that provides the kind of GPU that its container needs in order to work
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: "gpu.gpu-vendor.example/installed-memory"
            operator: Gt # (greater than)
            values: ["40535"]
          - key: "feature.node.kubernetes.io/pci-10.present" # NFD Feature label
            values: ["true"] # (optional) only schedule on nodes with PCI device 10
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU

Response: This yaml code Schedule GPUs | Items on this page refer to third party products or projects that provide functionality required by Kubernetes. The Kubernetes project authors aren't responsible for those third-party products or proj


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure

Response:
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU

Response: This yaml code Schedule GPUs | If different nodes in your cluster have different types of GPUs, then you can use Node Labels and Node Selectors to schedule pods to appropriate nodes.


Prompt:
Explain this shell code:

# Label your nodes with the accelerator type they have.
kubectl label nodes node1 accelerator=example-gpu-x100
kubectl label nodes node2 accelerator=other-gpu-k915

Response: This shell code Schedule GPUs | That label key accelerator is just an example; you can use a different label key if you prefer.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: example-vector-add
spec:
  restartPolicy: OnFailure
  # You can use Kubernetes node affinity to schedule this Pod onto a node
  # that provides the kind of GPU that its container needs in order to work
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:

Response:
        - matchExpressions:
          - key: "gpu.gpu-vendor.example/installed-memory"
            operator: Gt # (greater than)
            values: ["40535"]
          - key: "feature.node.kubernetes.io/pci-10.present" # NFD Feature label
            values: ["true"] # (optional) only schedule on nodes with PCI device 10
  containers:
    - name: example-vector-add
      image: "registry.example/example-vector-add:v42"
      resources:
        limits:
          gpu-vendor.example/example-gpu: 1 # requesting 1 GPU