Prompt:
Explain this text code:

NAME                           READY   STATUS    ...  IP           NODE
hello-world-2895499144-bsbk5   1/1     Running   ...  10.200.1.4   worker1
hello-world-2895499144-m1pwt   1/1     Running   ...  10.200.2.5   worker2

Response: This text code 10.5 - Use a Service to Access an Application in a Cluster | Get the public IP address of one of your nodes that is running a Hello World pod. How you get this address depends on how you set up your cluster. For example, if you are using Minikube, you can see t

Context: 10.5 - Use a Service to Access an Application in a Cluster | Get the public IP address of one of your nodes that is running a Hello World pod. How you get this address depends on how you set up your cluster. For example, if you are using Minikube, you can see t


Prompt:
Explain this text code:

Hello, world!
Version: 2.0.0
Hostname: hello-world-cdd4458f4-m47c8

Response: This text code 10.5 - Use a Service to Access an Application in a Cluster | As an alternative to using kubectl expose, you can use a service configuration file to create a Service.

Context: 10.5 - Use a Service to Access an Application in a Cluster | As an alternative to using kubectl expose, you can use a service configuration file to create a Service.


Prompt:
Complete this yaml code:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  selector:
    matchLabels:
      app: hello
      tier: backend
      track: stable
  replicas: 3
  template:

Response:
    metadata:
      labels:
        app: hello
        tier: backend
        track: stable
    spec:
      containers:
        - name: hello
          image: "gcr.io/google-samples/hello-go-gke:1.0"
          ports:
            - name: http
              containerPort: 80
...

Context: 10.6 - Connect a Frontend to a Backend Using Services | Create the backend Deployment:


Prompt:
Explain this yaml code:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  selector:
    matchLabels:
      app: hello
      tier: backend
      track: stable
  replicas: 3
  template:
    metadata:
      labels:
        app: hello
        tier: backend
        track: stable
    spec:
      containers:
        - name: hello
          image: "gcr.io/google-samples/hello-go-gke:1.0"
          ports:
            - name: http
              containerPort: 80
...

Response: This yaml code 10.6 - Connect a Frontend to a Backend Using Services | Create the backend Deployment:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/service/access/backend-deployment.yaml

Response: This bash code 10.6 - Connect a Frontend to a Backend Using Services | View information about the backend Deployment:

Context: 10.6 - Connect a Frontend to a Backend Using Services | View information about the backend Deployment:


Prompt:
Complete this text code:

Name:                           backend
Namespace:                      default
CreationTimestamp:              Mon, 24 Oct 2016 14:21:02 -0700
Labels:                         app=hello
                                tier=backend
                                track=stable
Annotations:                    deployment.kubernetes.io/revision=1
Selector:                       app=hello,tier=backend,track=stable
Replicas:                       3 desired | 3 updated | 3 total | 3 available | 0 unavailable
StrategyType:                   RollingUpdate
MinReadySeconds:                0
RollingUpdateStrategy:          1 max unavailable, 1 max surge
Pod Template:
  Labels:       app=hello
                tier=backend
                track=stable

Response:
  Containers:
   hello:
    Image:              "gcr.io/google-samples/hello-go-gke:1.0"
    Port:               80/TCP
    Environment:        <none>
    Mounts:             <none>
  Volumes:              <none>
Conditions:
  Type          Status  Reason
  ----          ------  ------
  Available     True    MinimumReplicasAvailable
  Progressing   True    NewReplicaSetAvailable
OldReplicaSets:                 <none>
NewReplicaSet:                  hello-3621623197 (3/3 replicas created)
Events:
...

Context: 10.6 - Connect a Frontend to a Backend Using Services | The key to sending requests from a frontend to a backend is the backend Service. A Service creates a persistent IP address and DNS name entry so that the backend microservice can always be reached. A


Prompt:
Explain this text code:

Name:                           backend
Namespace:                      default
CreationTimestamp:              Mon, 24 Oct 2016 14:21:02 -0700
Labels:                         app=hello
                                tier=backend
                                track=stable
Annotations:                    deployment.kubernetes.io/revision=1
Selector:                       app=hello,tier=backend,track=stable
Replicas:                       3 desired | 3 updated | 3 total | 3 available | 0 unavailable
StrategyType:                   RollingUpdate
MinReadySeconds:                0
RollingUpdateStrategy:          1 max unavailable, 1 max surge
Pod Template:
  Labels:       app=hello
                tier=backend
                track=stable
  Containers:
   hello:
    Image:              "gcr.io/google-samples/hello-go-gke:1.0"
    Port:               80/TCP
    Environment:        <none>
    Mounts:             <none>
  Volumes:              <none>
Conditions:
  Type          Status  Reason
  ----          ------  ------
  Available     True    MinimumReplicasAvailable
  Progressing   True    NewReplicaSetAvailable
OldReplicaSets:                 <none>
NewReplicaSet:                  hello-3621623197 (3/3 replicas created)
Events:
...

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | The key to sending requests from a frontend to a backend is the backend Service. A Service creates a persistent IP address and DNS name entry so that the backend microservice can always be reached. A


Prompt:
Complete this yaml code:

---
apiVersion: v1
kind: Service
metadata:
  name: hello
spec:
  selector:

Response:
    app: hello
    tier: backend
  ports:
  - protocol: TCP
    port: 80
    targetPort: http
...

Context: 10.6 - Connect a Frontend to a Backend Using Services | In the configuration file, you can see that the Service, named hello routes traffic to Pods that have the labels app: hello and tier: backend.


Prompt:
Explain this yaml code:

---
apiVersion: v1
kind: Service
metadata:
  name: hello
spec:
  selector:
    app: hello
    tier: backend
  ports:
  - protocol: TCP
    port: 80
    targetPort: http
...

Response: This yaml code 10.6 - Connect a Frontend to a Backend Using Services | In the configuration file, you can see that the Service, named hello routes traffic to Pods that have the labels app: hello and tier: backend.


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/service/access/backend-service.yaml

Response: This bash code 10.6 - Connect a Frontend to a Backend Using Services | At this point, you have a backend Deployment running three replicas of your hello application, and you have a Service that can route traffic to them. However, this service is neither available nor res

Context: 10.6 - Connect a Frontend to a Backend Using Services | At this point, you have a backend Deployment running three replicas of your hello application, and you have a Service that can route traffic to them. However, this service is neither available nor res


Prompt:
Complete this text code:

# The identifier Backend is internal to nginx, and used to name this specific upstream
upstream Backend {
    # hello is the internal DNS name used by the backend Service inside Kubernetes
    server hello;
}
server {

Response:
listen 80;
location / {
    # The following statement will proxy traffic to the upstream named Backend
    proxy_pass http://Backend;
}
}

Context: 10.6 - Connect a Frontend to a Backend Using Services | server { listen 80;


Prompt:
Explain this text code:

# The identifier Backend is internal to nginx, and used to name this specific upstream
upstream Backend {
    # hello is the internal DNS name used by the backend Service inside Kubernetes
    server hello;
}
server {
listen 80;
location / {
    # The following statement will proxy traffic to the upstream named Backend
    proxy_pass http://Backend;
}
}

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | server { listen 80;


Prompt:
Complete this text code:

location / {
    # The following statement will proxy traffic to the upstream named Backend

Response:
    proxy_pass http://Backend;
}

Context: 10.6 - Connect a Frontend to a Backend Using Services | }


Prompt:
Explain this text code:

location / {
    # The following statement will proxy traffic to the upstream named Backend
    proxy_pass http://Backend;
}

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | }


Prompt:
Complete this yaml code:

---
apiVersion: v1
kind: Service
metadata:
  name: frontend
spec:
  selector:

Response:
    app: hello
    tier: frontend
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  type: LoadBalancer
...

Context: 10.6 - Connect a Frontend to a Backend Using Services | Create the frontend Deployment and Service:


Prompt:
Explain this yaml code:

---
apiVersion: v1
kind: Service
metadata:
  name: frontend
spec:
  selector:
    app: hello
    tier: frontend
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  type: LoadBalancer
...

Response: This yaml code 10.6 - Connect a Frontend to a Backend Using Services | Create the frontend Deployment and Service:


Prompt:
Complete this yaml code:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  selector:
    matchLabels:
      app: hello
      tier: frontend
      track: stable
  replicas: 1
  template:

Response:
    metadata:
      labels:
        app: hello
        tier: frontend
        track: stable
    spec:
      containers:
        - name: nginx
          image: "gcr.io/google-samples/hello-frontend:1.0"
          lifecycle:
            preStop:
              exec:
                command: ["/usr/sbin/nginx","-s","quit"]
...


Prompt:
Explain this yaml code:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  selector:
    matchLabels:
      app: hello
      tier: frontend
      track: stable
  replicas: 1
  template:
    metadata:
      labels:
        app: hello
        tier: frontend
        track: stable
    spec:
      containers:
        - name: nginx
          image: "gcr.io/google-samples/hello-frontend:1.0"
          lifecycle:
            preStop:
              exec:
                command: ["/usr/sbin/nginx","-s","quit"]
...

Response: This yaml code 10.6 - Connect a Frontend to a Backend Using Services | Create the frontend Deployment and Service:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/service/access/frontend-deployment.yaml
kubectl apply -f https://k8s.io/examples/service/access/frontend-service.yaml

Response: This bash code 10.6 - Connect a Frontend to a Backend Using Services | The output verifies that both resources were created:

Context: 10.6 - Connect a Frontend to a Backend Using Services | The output verifies that both resources were created:


Prompt:
Explain this text code:

deployment.apps/frontend created
service/frontend created

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | Once you've created a Service of type LoadBalancer, you can use this command to find the external IP:

Context: 10.6 - Connect a Frontend to a Backend Using Services | Once you've created a Service of type LoadBalancer, you can use this command to find the external IP:


Prompt:
Explain this text code:

NAME       TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)  AGE
frontend   LoadBalancer   10.51.252.116   <pending>     80/TCP   10s

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | As soon as an external IP is provisioned, however, the configuration updates to include the new IP under the EXTERNAL-IP heading:

Context: 10.6 - Connect a Frontend to a Backend Using Services | As soon as an external IP is provisioned, however, the configuration updates to include the new IP under the EXTERNAL-IP heading:


Prompt:
Explain this text code:

NAME       TYPE           CLUSTER-IP      EXTERNAL-IP        PORT(S)  AGE
frontend   LoadBalancer   10.51.252.116   XXX.XXX.XXX.XXX    80/TCP   1m

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | That IP can now be used to interact with the frontend service from outside the cluster.

Context: 10.6 - Connect a Frontend to a Backend Using Services | That IP can now be used to interact with the frontend service from outside the cluster.


Prompt:
Explain this text code:

curl http://${EXTERNAL_IP} # replace this with the EXTERNAL-IP you saw earlier

Response: This text code 10.6 - Connect a Frontend to a Backend Using Services | The output shows the message generated by the backend:

Context: 10.6 - Connect a Frontend to a Backend Using Services | The output shows the message generated by the backend:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Service
metadata:
  name: example-service
spec:

Response:
  selector:
    app: example
  ports:
    - port: 8765
      targetPort: 9376
  type: LoadBalancer

Context: 10.7 - Create an External Load Balancer | You can alternatively create the service with the kubectl expose command and its --type=LoadBalancer flag:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Service
metadata:
  name: example-service
spec:
  selector:
    app: example
  ports:
    - port: 8765
      targetPort: 9376
  type: LoadBalancer

Response: This yaml code 10.7 - Create an External Load Balancer | You can alternatively create the service with the kubectl expose command and its --type=LoadBalancer flag:


Prompt:
Explain this bash code:

kubectl expose deployment example --port=8765 --target-port=9376 \
        --name=example-service --type=LoadBalancer

Response: This bash code 10.7 - Create an External Load Balancer | This command creates a new Service using the same selectors as the referenced resource (in the case of the example above, a Deployment named example).

Context: 10.7 - Create an External Load Balancer | This command creates a new Service using the same selectors as the referenced resource (in the case of the example above, a Deployment named example).


Prompt:
Complete this text code:

Name:                     example-service
Namespace:                default
Labels:                   app=example
Annotations:              <none>
Selector:                 app=example
Type:                     LoadBalancer
IP Families:              <none>
IP:                       10.3.22.96

Response:
IPs:                      10.3.22.96
LoadBalancer Ingress:     192.0.2.89
Port:                     <unset>  8765/TCP
TargetPort:               9376/TCP
NodePort:                 <unset>  30593/TCP
Endpoints:                172.17.0.3:9376
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Context: 10.7 - Create an External Load Balancer | The load balancer's IP address is listed next to LoadBalancer Ingress.


Prompt:
Explain this text code:

Name:                     example-service
Namespace:                default
Labels:                   app=example
Annotations:              <none>
Selector:                 app=example
Type:                     LoadBalancer
IP Families:              <none>
IP:                       10.3.22.96
IPs:                      10.3.22.96
LoadBalancer Ingress:     192.0.2.89
Port:                     <unset>  8765/TCP
TargetPort:               9376/TCP
NodePort:                 <unset>  30593/TCP
Endpoints:                172.17.0.3:9376
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Response: This text code 10.7 - Create an External Load Balancer | The load balancer's IP address is listed next to LoadBalancer Ingress.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Service
metadata:
  name: example-service
spec:
  selector:

Response:
    app: example
  ports:
    - port: 8765
      targetPort: 9376
  externalTrafficPolicy: Local
  type: LoadBalancer

Context: 10.7 - Create an External Load Balancer | Load balancing services from some cloud providers do not let you configure different weights for each target.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Service
metadata:
  name: example-service
spec:
  selector:
    app: example
  ports:
    - port: 8765
      targetPort: 9376
  externalTrafficPolicy: Local
  type: LoadBalancer

Response: This yaml code 10.7 - Create an External Load Balancer | Load balancing services from some cloud providers do not let you configure different weights for each target.


Prompt:
Complete this bash code:

kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec['initContainers', 'containers'][*].image}" |\
tr -s '[[:space:]]' '\n' |\

Response:
sort |\
uniq -c

Context: 10.8 - List All Container Images Running in a Cluster | The jsonpath is interpreted as follows:


Prompt:
Explain this bash code:

kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec['initContainers', 'containers'][*].image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c

Response: This bash code 10.8 - List All Container Images Running in a Cluster | The jsonpath is interpreted as follows:


Prompt:
Explain this bash code:

kubectl get pods --all-namespaces -o jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |\
sort

Response: This bash code 10.8 - List All Container Images Running in a Cluster | To target only Pods matching a specific label, use the -l flag. The following matches only Pods with labels matching app=nginx.

Context: 10.8 - List All Container Images Running in a Cluster | To target only Pods matching a specific label, use the -l flag. The following matches only Pods with labels matching app=nginx.


Prompt:
Explain this bash code:

kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" -l app=nginx

Response: This bash code 10.8 - List All Container Images Running in a Cluster | To target only pods in a specific namespace, use the namespace flag. The following matches only Pods in the kube-system namespace.

Context: 10.8 - List All Container Images Running in a Cluster | To target only pods in a specific namespace, use the namespace flag. The following matches only Pods in the kube-system namespace.


Prompt:
Explain this bash code:

kubectl get pods --namespace kube-system -o jsonpath="{.items[*].spec.containers[*].image}"

Response: This bash code 10.8 - List All Container Images Running in a Cluster | As an alternative to jsonpath, Kubectl supports using go-templates for formatting the output:

Context: 10.8 - List All Container Images Running in a Cluster | As an alternative to jsonpath, Kubectl supports using go-templates for formatting the output:


Prompt:
Explain this bash code:

kubectl get pods --all-namespaces -o go-template --template="{{range .items}}{{range .spec.containers}}{{.image}} {{end}}{{end}}"

Response: This bash code 10.8 - List All Container Images Running in a Cluster | An Ingress is an API object that defines rules which allow external access to services in a cluster. An Ingress controller fulfills the rules set in the Ingress.

Context: 10.8 - List All Container Images Running in a Cluster | An Ingress is an API object that defines rules which allow external access to services in a cluster. An Ingress controller fulfills the rules set in the Ingress.


Prompt:
Complete this text code:

NAME                                        READY   STATUS      RESTARTS    AGE
ingress-nginx-admission-create-g9g49        0/1     Completed   0          11m

Response:
ingress-nginx-admission-patch-rqp78         0/1     Completed   1          11m
ingress-nginx-controller-59b45fb494-26npt   1/1     Running     0          11m

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Create a Deployment using the following command:


Prompt:
Explain this text code:

NAME                                        READY   STATUS      RESTARTS    AGE
ingress-nginx-admission-create-g9g49        0/1     Completed   0          11m
ingress-nginx-admission-patch-rqp78         0/1     Completed   1          11m
ingress-nginx-controller-59b45fb494-26npt   1/1     Running     0          11m

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Create a Deployment using the following command:


Prompt:
Explain this bash code:

kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0

Response: This bash code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output should be:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output should be:


Prompt:
Explain this text code:

NAME   READY   UP-TO-DATE   AVAILABLE   AGE
web    1/1     1            1           53s

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Expose the Deployment:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Expose the Deployment:


Prompt:
Explain this bash code:

kubectl expose deployment web --type=NodePort --port=8080

Response: This bash code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output should be:


Prompt:
Explain this text code:

NAME      TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
web       NodePort   10.104.133.249   <none>        8080:31637/TCP   12m

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Visit the Service via NodePort, using the minikube service command. Follow the instructions for your platform:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Visit the Service via NodePort, using the minikube service command. Follow the instructions for your platform:


Prompt:
Explain this text code:

# The command must be run in a separate terminal.
minikube service web --url

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output is similar to:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output is similar to:


Prompt:
Explain this text code:

http://127.0.0.1:62445
! Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | From a different terminal, invoke the URL obtained in the output of the previous step:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | From a different terminal, invoke the URL obtained in the output of the previous step:


Prompt:
Explain this text code:

Hello, world!
Version: 1.0.0
Hostname: web-55b8c6998d-8k564

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | You can now access the sample application via the Minikube IP address and NodePort. The next step lets you access the application using the Ingress resource.

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | You can now access the sample application via the Minikube IP address and NodePort. The next step lets you access the application using the Ingress resource.


Prompt:
Complete this yaml code:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  ingressClassName: nginx
  rules:
    - host: hello-world.example

Response:
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 8080

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Create the Ingress object by running the following command:


Prompt:
Explain this yaml code:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  ingressClassName: nginx
  rules:
    - host: hello-world.example
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 8080

Response: This yaml code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Create the Ingress object by running the following command:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml

Response: This bash code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output should be:


Prompt:
Explain this text code:

NAME              CLASS   HOSTS                 ADDRESS        PORTS   AGE
example-ingress   nginx   hello-world.example   172.17.0.15    80      38s

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Verify that the Ingress controller is directing traffic, by following the instructions for your platform:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Verify that the Ingress controller is directing traffic, by following the instructions for your platform:


Prompt:
Explain this text code:

curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | minikube tunnel The output is similar to:Tunnel successfully started NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ... The service/ingress e

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | minikube tunnel The output is similar to:Tunnel successfully started NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ... The service/ingress e


Prompt:
Complete this text code:

Tunnel successfully started

NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

Response:
The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
sudo permission will be asked for it.
Starting tunnel for service example-ingress.

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | From within a new terminal, invoke the following command:


Prompt:
Explain this text code:

Tunnel successfully started

NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
sudo permission will be asked for it.
Starting tunnel for service example-ingress.

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | From within a new terminal, invoke the following command:


Prompt:
Explain this text code:

curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Optionally, you can also visit hello-world.example from your browser.

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Optionally, you can also visit hello-world.example from your browser.


Prompt:
Explain this text code:

Hello, world!
Version: 1.0.0
Hostname: web-55b8c6998d-8k564

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Optionally, you can also visit hello-world.example from your browser.


Prompt:
Explain this bash code:

kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:2.0

Response: This bash code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output should be:


Prompt:
Explain this text code:

NAME   READY   UP-TO-DATE   AVAILABLE   AGE
web2   1/1     1            1           16s

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Expose the second Deployment:

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Expose the second Deployment:


Prompt:
Explain this bash code:

kubectl expose deployment web2 --port=8080 --type=NodePort

Response: This bash code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output should be:


Prompt:
Complete this text code:

- path: /v2
  pathType: Prefix
  backend:

Response:
    service:
      name: web2
      port:
        number: 8080

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Apply the changes:


Prompt:
Explain this text code:

- path: /v2
  pathType: Prefix
  backend:
    service:
      name: web2
      port:
        number: 8080

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Apply the changes:


Prompt:
Explain this text code:

curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | minikube tunnel The output is similar to:Tunnel successfully started NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ... The service/ingress e


Prompt:
Complete this text code:

Tunnel successfully started

NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

Response:
The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
sudo permission will be asked for it.
Starting tunnel for service example-ingress.


Prompt:
Explain this text code:

Tunnel successfully started

NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
sudo permission will be asked for it.
Starting tunnel for service example-ingress.

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | From within a new terminal, invoke the following command:


Prompt:
Explain this text code:

curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output is similar to:


Prompt:
Explain this text code:

Hello, world!
Version: 1.0.0
Hostname: web-55b8c6998d-8k564

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Access the 2nd version of the Hello World app.

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | Access the 2nd version of the Hello World app.


Prompt:
Explain this text code:

curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example/v2

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | minikube tunnel The output is similar to:Tunnel successfully started NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ... The service/ingress e


Prompt:
Complete this text code:

Tunnel successfully started

NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

Response:
The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
sudo permission will be asked for it.
Starting tunnel for service example-ingress.


Prompt:
Explain this text code:

Tunnel successfully started

NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
sudo permission will be asked for it.
Starting tunnel for service example-ingress.

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | From within a new terminal, invoke the following command:


Prompt:
Explain this text code:

curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example/v2

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | The output is similar to:


Prompt:
Explain this text code:

Hello, world!
Version: 2.0.0
Hostname: web2-75cd47646f-t8cjk

Response: This text code 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | This page shows how to use a Volume to communicate between two Containers running in the same Pod. See also how to allow processes to communicate by sharing process namespace between containers.

Context: 10.9 - Set up Ingress on Minikube with the NGINX Ingress Controller | This page shows how to use a Volume to communicate between two Containers running in the same Pod. See also how to allow processes to communicate by sharing process namespace between containers.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:

  restartPolicy: Never

  volumes:
  - name: shared-data
    emptyDir: {}

  containers:

Response:
  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html

  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | In the configuration file, you can see that the Pod has a Volume named shared-data.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:

  restartPolicy: Never

  volumes:
  - name: shared-data
    emptyDir: {}

  containers:

  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html

  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]

Response: This yaml code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | In the configuration file, you can see that the Pod has a Volume named shared-data.


Prompt:
Explain this text code:

echo Hello from the debian container > /pod-data/index.html

Response: This text code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | Notice that the second container writes the index.html file in the root directory of the nginx server.

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | Notice that the second container writes the index.html file in the root directory of the nginx server.


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/pods/two-container-pod.yaml

Response: This bash code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | View information about the Pod and the Containers:

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | View information about the Pod and the Containers:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  ...
  name: two-containers
  namespace: default
  ...
spec:
  ...
  containerStatuses:

  - containerID: docker://c1d8abd1 ...
    image: debian
    ...

Response:
    lastState:
      terminated:
        ...
    name: debian-container
    ...

  - containerID: docker://96c1ff2c5bb ...
    image: nginx
    ...
    name: nginx-container
    ...
    state:
      running:
    ...

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | You can see that the debian Container has terminated, and the nginx Container is still running.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  ...
  name: two-containers
  namespace: default
  ...
spec:
  ...
  containerStatuses:

  - containerID: docker://c1d8abd1 ...
    image: debian
    ...
    lastState:
      terminated:
        ...
    name: debian-container
    ...

  - containerID: docker://96c1ff2c5bb ...
    image: nginx
    ...
    name: nginx-container
    ...
    state:
      running:
    ...

Response: This yaml code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | You can see that the debian Container has terminated, and the nginx Container is still running.


Prompt:
Explain this bash code:

kubectl exec -it two-containers -c nginx-container -- /bin/bash

Response: This bash code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | In your shell, verify that nginx is running:

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | In your shell, verify that nginx is running:


Prompt:
Explain this text code:

root@two-containers:/# apt-get update
root@two-containers:/# apt-get install curl procps
root@two-containers:/# ps aux

Response: This text code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | The output is similar to this:

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | The output is similar to this:


Prompt:
Explain this text code:

USER       PID  ...  STAT START   TIME COMMAND
root         1  ...  Ss   21:12   0:00 nginx: master process nginx -g daemon off;

Response: This text code 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | Recall that the debian Container created the index.html file in the nginx root directory. Use curl to send a GET request to the nginx server:

Context: 10.10 - Communicate Between Containers in the Same Pod Using a Shared Volume | Recall that the debian Container created the index.html file in the nginx root directory. Use curl to send a GET request to the nginx server:


Prompt:
Complete this text code:

Kubernetes master is running at https://192.0.2.1
elasticsearch-logging is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy
kibana-logging is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/kibana-logging/proxy

Response:
kube-dns is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/kube-dns/proxy
grafana is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
heapster is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/monitoring-heapster/proxy

Context: 10.12 - Access Services Running on Clusters | This shows the proxy-verb URL for accessing each service. For example, this cluster has cluster-level logging enabled (using Elasticsearch), which can be reached at https://192.0.2.1/api/v1/namespaces


Prompt:
Explain this text code:

Kubernetes master is running at https://192.0.2.1
elasticsearch-logging is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy
kibana-logging is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/kibana-logging/proxy
kube-dns is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/kube-dns/proxy
grafana is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
heapster is running at https://192.0.2.1/api/v1/namespaces/kube-system/services/monitoring-heapster/proxy

Response: This text code 10.12 - Access Services Running on Clusters | This shows the proxy-verb URL for accessing each service. For example, this cluster has cluster-level logging enabled (using Elasticsearch), which can be reached at https://192.0.2.1/api/v1/namespaces


Prompt:
Explain this text code:

http://192.0.2.1/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/_search?q=user:kimchy

Response: This text code 10.12 - Access Services Running on Clusters | To access the Elasticsearch cluster health information _cluster/health?pretty=true, you would use:

Context: 10.12 - Access Services Running on Clusters | To access the Elasticsearch cluster health information _cluster/health?pretty=true, you would use:


Prompt:
Explain this text code:

https://192.0.2.1/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/_cluster/health?pretty=true

Response: This text code 10.12 - Access Services Running on Clusters | The health information is similar to this:

Context: 10.12 - Access Services Running on Clusters | The health information is similar to this:


Prompt:
Complete this json code:

{
  "cluster_name" : "kubernetes_logging",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,

Response:
  "active_primary_shards" : 5,
  "active_shards" : 5,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 5
}

Context: 10.12 - Access Services Running on Clusters | To access the https Elasticsearch service health information _cluster/health?pretty=true, you would use:


Prompt:
Explain this json code:

{
  "cluster_name" : "kubernetes_logging",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 5,
  "active_shards" : 5,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 5
}

Response: This json code 10.12 - Access Services Running on Clusters | To access the https Elasticsearch service health information _cluster/health?pretty=true, you would use:


Prompt:
Explain this text code:

https://192.0.2.1/api/v1/namespaces/kube-system/services/https:elasticsearch-logging:/proxy/_cluster/health?pretty=true

Response: This text code 10.12 - Access Services Running on Clusters | You may be able to put an apiserver proxy URL into the address bar of a browser. However:

Context: 10.12 - Access Services Running on Clusters | You may be able to put an apiserver proxy URL into the address bar of a browser. However:


Prompt:
Complete this text code:

--requestheader-client-ca-file=<path to aggregator CA cert>
--requestheader-allowed-names=front-proxy-client
--requestheader-extra-headers-prefix=X-Remote-Extra-

Response:
--requestheader-group-headers=X-Remote-Group
--requestheader-username-headers=X-Remote-User
--proxy-client-cert-file=<path to aggregator proxy cert>
--proxy-client-key-file=<path to aggregator proxy key>

Context: 11.1 - Configure the Aggregation Layer | The Kubernetes apiserver has two client CA options:


Prompt:
Explain this text code:

--requestheader-client-ca-file=<path to aggregator CA cert>
--requestheader-allowed-names=front-proxy-client
--requestheader-extra-headers-prefix=X-Remote-Extra-
--requestheader-group-headers=X-Remote-Group
--requestheader-username-headers=X-Remote-User
--proxy-client-cert-file=<path to aggregator proxy cert>
--proxy-client-key-file=<path to aggregator proxy key>

Response: This text code 11.1 - Configure the Aggregation Layer | The Kubernetes apiserver has two client CA options:


Prompt:
Complete this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  name: <name of the registration object>
spec:
  group: <API group name this extension apiserver hosts>

Response:
  version: <API version this extension apiserver hosts>
  groupPriorityMinimum: <priority this APIService for this group, see API documentation>
  versionPriority: <prioritizes ordering of this version within a group, see API documentation>
  service:
    namespace: <namespace of the extension apiserver service>
    name: <name of the extension apiserver service>
  caBundle: <pem encoded ca cert that signs the server cert used by the webhook>

Context: 11.1 - Configure the Aggregation Layer | The name of an APIService object must be a valid path segment name.


Prompt:
Explain this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  name: <name of the registration object>
spec:
  group: <API group name this extension apiserver hosts>
  version: <API version this extension apiserver hosts>
  groupPriorityMinimum: <priority this APIService for this group, see API documentation>
  versionPriority: <prioritizes ordering of this version within a group, see API documentation>
  service:
    namespace: <namespace of the extension apiserver service>
    name: <name of the extension apiserver service>
  caBundle: <pem encoded ca cert that signs the server cert used by the webhook>

Response: This yaml code 11.1 - Configure the Aggregation Layer | The name of an APIService object must be a valid path segment name.


Prompt:
Complete this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
...
spec:
  ...

Response:
  service:
    namespace: my-service-namespace
    name: my-service-name
    port: 1234
  caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...

Context: 11.1 - Configure the Aggregation Layer | This page shows how to install a custom resource into the Kubernetes API by creating a CustomResourceDefinition.


Prompt:
Explain this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
...
spec:
  ...
  service:
    namespace: my-service-namespace
    name: my-service-name
    port: 1234
  caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...

Response: This yaml code 11.1 - Configure the Aggregation Layer | This page shows how to install a custom resource into the Kubernetes API by creating a CustomResourceDefinition.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:

Response:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this text code:

/apis/stable.example.com/v1/namespaces/*/crontabs/...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This endpoint URL can then be used to create and manage custom objects. The kind of these objects will be CronTab from the spec of the CustomResourceDefinition object you created above.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This endpoint URL can then be used to create and manage custom objects. The kind of these objects will be CronTab from the spec of the CustomResourceDefinition object you created above.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:

Response:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Complete this yaml code:

apiVersion: v1
items:
- apiVersion: stable.example.com/v1
  kind: CronTab
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"stable.example.com/v1","kind":"CronTab","metadata":{"annotations":{},"name":"my-new-cron-object","namespace":"default"},"spec":{"cronSpec":"* * * * */5","image":"my-awesome-cron-image"}}
    creationTimestamp: "2021-06-20T07:35:27Z"
    generation: 1

Response:
    name: my-new-cron-object
    namespace: default
    resourceVersion: "1326"
    uid: 9aab1d66-628e-41bb-a422-57b8b3b1f5a9
  spec:
    cronSpec: '* * * * */5'
    image: my-awesome-cron-image
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint and delete all custom objects stored in it.


Prompt:
Explain this yaml code:

apiVersion: v1
items:
- apiVersion: stable.example.com/v1
  kind: CronTab
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"stable.example.com/v1","kind":"CronTab","metadata":{"annotations":{},"name":"my-new-cron-object","namespace":"default"},"spec":{"cronSpec":"* * * * */5","image":"my-awesome-cron-image"}}
    creationTimestamp: "2021-06-20T07:35:27Z"
    generation: 1
    name: my-new-cron-object
    namespace: default
    resourceVersion: "1326"
    uid: 9aab1d66-628e-41bb-a422-57b8b3b1f5a9
  spec:
    cronSpec: '* * * * */5'
    image: my-awesome-cron-image
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint and delete all custom objects stored in it.


Prompt:
Explain this bash code:

kubectl delete -f resourcedefinition.yaml
kubectl get crontabs

Response: This bash code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you later recreate the same CustomResourceDefinition, it will start out empty.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you later recreate the same CustomResourceDefinition, it will start out empty.


Prompt:
Explain this text code:

Error from server (NotFound): Unable to list {"stable.example.com" "v1" "crontabs"}: the server could not
find the requested resource (get crontabs.stable.example.com)

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you later recreate the same CustomResourceDefinition, it will start out empty.


Prompt:
Complete this text code:

properties:
  foo:
    # ...

Response:
allOf:
- properties:
    foo:
      # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 2:


Prompt:
Explain this text code:

properties:
  foo:
    # ...
allOf:
- properties:
    foo:
      # ...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 2:


Prompt:
Complete this text code:

allOf:
- items:

Response:
    properties:
      foo:
        # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | conflicts with rule 2. The following would be correct:


Prompt:
Explain this text code:

allOf:
- items:
    properties:
      foo:
        # ...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | conflicts with rule 2. The following would be correct:


Prompt:
Complete this text code:

items:
  properties:
    foo:
      # ...

Response:
allOf:
- items:
    properties:
      foo:
        # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 3:


Prompt:
Explain this text code:

items:
  properties:
    foo:
      # ...
allOf:
- items:
    properties:
      foo:
        # ...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 3:


Prompt:
Complete this text code:

properties:
  foo:
    pattern: "abc"
  metadata:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
      finalizers:

Response:
        type: array
        items:
          type: string
          pattern: "my-finalizer"
anyOf:
- properties:
    bar:
      type: integer
      minimum: 42
  required: ["bar"]
  description: "foo bar object"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is not a structural schema because of the following violations:


Prompt:
Explain this text code:

properties:
  foo:
    pattern: "abc"
  metadata:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
      finalizers:
        type: array
        items:
          type: string
          pattern: "my-finalizer"
anyOf:
- properties:
    bar:
      type: integer
      minimum: 42
  required: ["bar"]
  description: "foo bar object"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is not a structural schema because of the following violations:


Prompt:
Complete this text code:

type: object
description: "foo bar object"
properties:
  foo:
    type: string
    pattern: "abc"
  bar:
    type: integer
  metadata:

Response:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
anyOf:
- properties:
    bar:
      minimum: 42
  required: ["bar"]

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Violations of the structural schema rules are reported in the NonStructural condition in the CustomResourceDefinition.


Prompt:
Explain this text code:

type: object
description: "foo bar object"
properties:
  foo:
    type: string
    pattern: "abc"
  bar:
    type: integer
  metadata:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
anyOf:
- properties:
    bar:
      minimum: 42
  required: ["bar"]

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Violations of the structural schema rules are reported in the NonStructural condition in the CustomResourceDefinition.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  someRandomField: 42


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  someRandomField: 42

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this bash code:

kubectl create --validate=false -f my-crontab.yaml -o yaml

Response: This bash code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Your output is similar to:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Your output is similar to:


Prompt:
Complete this yaml code:

apiVersion: stable.example.com/v1
kind: CronTab
metadata:
  creationTimestamp: 2017-05-31T12:56:35Z
  generation: 1
  name: my-new-cron-object

Response:
  namespace: default
  resourceVersion: "285"
  uid: 9423255b-4600-11e7-af6a-28d2447dc82b
spec:
  cronSpec: '* * * * */5'
  image: my-awesome-cron-image

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Notice that the field someRandomField was pruned.


Prompt:
Explain this yaml code:

apiVersion: stable.example.com/v1
kind: CronTab
metadata:
  creationTimestamp: 2017-05-31T12:56:35Z
  generation: 1
  name: my-new-cron-object
  namespace: default
  resourceVersion: "285"
  uid: 9423255b-4600-11e7-af6a-28d2447dc82b
spec:
  cronSpec: '* * * * */5'
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Notice that the field someRandomField was pruned.


Prompt:
Complete this text code:

type: object
properties:

Response:
  json:
    x-kubernetes-preserve-unknown-fields: true

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The field json can store any JSON value, without anything being pruned.


Prompt:
Explain this text code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The field json can store any JSON value, without anything being pruned.


Prompt:
Complete this text code:

type: object
properties:
  json:

Response:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    description: this is arbitrary JSON

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, only object type values are allowed.


Prompt:
Explain this text code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    description: this is arbitrary JSON

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, only object type values are allowed.


Prompt:
Complete this text code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    properties:

Response:
      spec:
        type: object
        properties:
          foo:
            type: string
          bar:
            type: string

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, the value:


Prompt:
Explain this text code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    properties:
      spec:
        type: object
        properties:
          foo:
            type: string
          bar:
            type: string

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, the value:


Prompt:
Complete this text code:

json:
  spec:
    foo: abc

Response:
    bar: def
    something: x
  status:
    something: x

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is pruned to:


Prompt:
Explain this text code:

json:
  spec:
    foo: abc
    bar: def
    something: x
  status:
    something: x

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is pruned to:


Prompt:
Complete this text code:

json:
  spec:
    foo: abc

Response:
    bar: def
  status:
    something: x

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This means that the something field in the specified spec object is pruned, but everything outside is not.


Prompt:
Explain this text code:

json:
  spec:
    foo: abc
    bar: def
  status:
    something: x

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This means that the something field in the specified spec object is pruned, but everything outside is not.


Prompt:
Complete this text code:

type: object
properties:

Response:
  foo:
    x-kubernetes-int-or-string: true

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Also those nodes are partially excluded from rule 3 in the sense that the following two patterns are allowed (exactly those, without variations in order to additional fields):


Prompt:
Explain this text code:

type: object
properties:
  foo:
    x-kubernetes-int-or-string: true

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Also those nodes are partially excluded from rule 3 in the sense that the following two patterns are allowed (exactly those, without variations in order to additional fields):


Prompt:
Complete this text code:

x-kubernetes-int-or-string: true
anyOf:

Response:
  - type: integer
  - type: string
...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and


Prompt:
Explain this text code:

x-kubernetes-int-or-string: true
anyOf:
  - type: integer
  - type: string
...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and


Prompt:
Complete this text code:

x-kubernetes-int-or-string: true
allOf:
  - anyOf:

Response:
      - type: integer
      - type: string
  - # ... zero or more
...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With one of those specification, both an integer and a string validate.


Prompt:
Explain this text code:

x-kubernetes-int-or-string: true
allOf:
  - anyOf:
      - type: integer
      - type: string
  - # ... zero or more
...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With one of those specification, both an integer and a string validate.


Prompt:
Complete this text code:

type: object
properties:

Response:
  foo:
    x-kubernetes-embedded-resource: true
    x-kubernetes-preserve-unknown-fields: true

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Here, the field foo holds a complete object, e.g.:


Prompt:
Explain this text code:

type: object
properties:
  foo:
    x-kubernetes-embedded-resource: true
    x-kubernetes-preserve-unknown-fields: true

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Here, the field foo holds a complete object, e.g.:


Prompt:
Complete this yaml code:

foo:
  apiVersion: v1

Response:
  kind: Pod
  spec:
    # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Because x-kubernetes-preserve-unknown-fields: true is specified alongside, nothing is pruned. The use of x-kubernetes-preserve-unknown-fields: true is optional though.


Prompt:
Explain this yaml code:

foo:
  apiVersion: v1
  kind: Pod
  spec:
    # ...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Because x-kubernetes-preserve-unknown-fields: true is specified alongside, nothing is pruned. The use of x-kubernetes-preserve-unknown-fields: true is optional though.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab

Response:
metadata:
  finalizers:
  - stable.example.com/finalizer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Identifiers of custom finalizers consist of a domain name, a forward slash and the name of the finalizer. Any controller can add a finalizer to any object's list of finalizers.


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  finalizers:
  - stable.example.com/finalizer

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Identifiers of custom finalizers consist of a domain name, a forward slash and the name of the finalizer. Any controller can add a finalizer to any object's list of finalizers.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object

Response:
              properties:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * *"
  image: my-awesome-cron-image
  replicas: 15

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and attempt to create it:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * *"
  image: my-awesome-cron-image
  replicas: 15

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and attempt to create it:


Prompt:
Complete this text code:

The CronTab "my-new-cron-object" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"stable.example.com/v1", "kind":"CronTab", "metadata":map[string]interface {}{"name":"my-new-cron-object", "namespace":"default", "deletionTimestamp":interface {}(nil), "deletionGracePeriodSeconds":(*int64)(nil), "creationTimestamp":"2017-09-05T05:20:07Z", "uid":"e14d79e7-91f9-11e7-a598-f0761cb232d1", "clusterName":""}, "spec":map[string]interface {}{"cronSpec":"* * * *", "image":"my-awesome-cron-image", "replicas":15}}:
validation failure list:

Response:
spec.cronSpec in body should match '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
spec.replicas in body should be less than or equal to 10

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the fields contain valid values, the object creation request is accepted.


Prompt:
Explain this text code:

The CronTab "my-new-cron-object" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"stable.example.com/v1", "kind":"CronTab", "metadata":map[string]interface {}{"name":"my-new-cron-object", "namespace":"default", "deletionTimestamp":interface {}(nil), "deletionGracePeriodSeconds":(*int64)(nil), "creationTimestamp":"2017-09-05T05:20:07Z", "uid":"e14d79e7-91f9-11e7-a598-f0761cb232d1", "clusterName":""}, "spec":map[string]interface {}{"cronSpec":"* * * *", "image":"my-awesome-cron-image", "replicas":15}}:
validation failure list:
spec.cronSpec in body should match '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
spec.replicas in body should be less than or equal to 10

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the fields contain valid values, the object creation request is accepted.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  replicas: 5

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | And create it:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  replicas: 5

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | And create it:


Prompt:
Explain this bash code:

kubectl apply -f my-crontab.yaml
crontab "my-new-cron-object" created

Response: This bash code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you are using a version of Kubernetes older than v1.30, you need to explicitly enable the CRDValidationRatcheting feature gate to use this behavior, which then applies to all CustomResourceDefiniti

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you are using a version of Kubernetes older than v1.30, you need to explicitly enable the CRDValidationRatcheting feature gate to use this behavior, which then applies to all CustomResourceDefiniti


Prompt:
Complete this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "self.minReplicas <= self.replicas"
            message: "replicas should be greater than or equal to minReplicas."
          - rule: "self.replicas <= self.maxReplicas"
            message: "replicas should be smaller than or equal to maxReplicas."

Response:
        properties:
          # ...
          minReplicas:
            type: integer
          replicas:
            type: integer
          maxReplicas:
            type: integer
        required:
          - minReplicas
          - replicas
          - maxReplicas

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | will reject a request to create this custom resource:


Prompt:
Explain this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "self.minReplicas <= self.replicas"
            message: "replicas should be greater than or equal to minReplicas."
          - rule: "self.replicas <= self.maxReplicas"
            message: "replicas should be smaller than or equal to maxReplicas."
        properties:
          # ...
          minReplicas:
            type: integer
          replicas:
            type: integer
          maxReplicas:
            type: integer
        required:
          - minReplicas
          - replicas
          - maxReplicas

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | will reject a request to create this custom resource:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  minReplicas: 0
  replicas: 20
  maxReplicas: 10

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | with the response:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  minReplicas: 0
  replicas: 20
  maxReplicas: 10

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | with the response:


Prompt:
Explain this text code:

The CronTab "my-new-cron-object" is invalid:
* spec: Invalid value: map[string]interface {}{"maxReplicas":10, "minReplicas":0, "replicas":20}: replicas should be smaller than or equal to maxReplicas.

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | x-kubernetes-validations could have multiple rules. The rule under x-kubernetes-validations represents the expression which will be evaluated by CEL. The message represents the message displayed when

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | x-kubernetes-validations could have multiple rules. The rule under x-kubernetes-validations represents the expression which will be evaluated by CEL. The message represents the message displayed when


Prompt:
Explain this text code:

The CronTab "my-new-cron-object" is invalid:
* spec: Invalid value: map[string]interface {}{"maxReplicas":10, "minReplicas":0, "replicas":20}: failed rule: self.replicas <= self.maxReplicas

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation rules are compiled when CRDs are created/updated. The request of CRDs create/update will fail if compilation of validation rules fail. Compilation process includes type checking as well.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation rules are compiled when CRDs are created/updated. The request of CRDs create/update will fail if compilation of validation rules fail. Compilation process includes type checking as well.


Prompt:
Explain this text code:

Invalid value: apiextensions.ValidationRule{Rule:"self == true", Message:""}: compilation failed: ERROR: \<input>:1:6: found no matching overload for '_==_' applied to '(int, bool)'

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | no_such_field: does not contain the desired field.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | no_such_field: does not contain the desired field.


Prompt:
Explain this text code:

Invalid value: apiextensions.ValidationRule{Rule:"self.nonExistingField > 0", Message:""}: compilation failed: ERROR: \<input>:1:5: undefined field 'nonExistingField'

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | invalid argument: invalid argument to macros.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | invalid argument: invalid argument to macros.


Prompt:
Explain this text code:

Invalid value: apiextensions.ValidationRule{Rule:"has(self)", Message:""}: compilation failed: ERROR: <input>:1:4: invalid argument to has() macro

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation Rules Examples:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation Rules Examples:


Prompt:
Complete this text code:

# ...
  openAPIV3Schema:
    type: object
    x-kubernetes-validations:
      - rule: "self.status.availableReplicas >= self.spec.minReplicas"
    properties:
        spec:
          type: object

Response:
          properties:
            minReplicas:
              type: integer
            # ...
        status:
          type: object
          properties:
            availableReplicas:
              type: integer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable via self.field and field presence can be checked via has(self.field). Null valued field


Prompt:
Explain this text code:

# ...
  openAPIV3Schema:
    type: object
    x-kubernetes-validations:
      - rule: "self.status.availableReplicas >= self.spec.minReplicas"
    properties:
        spec:
          type: object
          properties:
            minReplicas:
              type: integer
            # ...
        status:
          type: object
          properties:
            availableReplicas:
              type: integer

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable via self.field and field presence can be checked via has(self.field). Null valued field


Prompt:
Complete this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object

Response:
        x-kubernetes-validations:
          - rule: "has(self.foo)"
        properties:
          # ...
          foo:
            type: integer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map are accessible via self[mapKey], map containment can be checked via mapKey in self and all entries of the


Prompt:
Explain this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "has(self.foo)"
        properties:
          # ...
          foo:
            type: integer

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map are accessible via self[mapKey], map containment can be checked via mapKey in self and all entries of the


Prompt:
Complete this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:

Response:
          - rule: "self['xyz'].foo > 0"
        additionalProperties:
          # ...
          type: object
          properties:
            foo:
              type: integer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an array, the elements of the array are accessible via self[i] and also by macros and functions.


Prompt:
Explain this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "self['xyz'].foo > 0"
        additionalProperties:
          # ...
          type: object
          properties:
            foo:
              type: integer

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an array, the elements of the array are accessible via self[i] and also by macros and functions.


Prompt:
Complete this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      # ...

Response:
      foo:
        type: array
        x-kubernetes-validations:
          - rule: "size(self) == 1"
        items:
          type: string

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to a scalar, self is bound to the scalar value.


Prompt:
Explain this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      # ...
      foo:
        type: array
        x-kubernetes-validations:
          - rule: "size(self) == 1"
        items:
          type: string

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to a scalar, self is bound to the scalar value.


Prompt:
Complete this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object

Response:
        properties:
          # ...
          foo:
            type: integer
            x-kubernetes-validations:
            - rule: "self > 0"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Examples:


Prompt:
Explain this text code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        properties:
          # ...
          foo:
            type: integer
            x-kubernetes-validations:
            - rule: "self > 0"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Examples:


Prompt:
Explain this text code:

x-kubernetes-validations:
- rule: "self.x <= self.maxLimit"
  messageExpression: '"x exceeded max limit of " + string(self.maxLimit)'

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Keep in mind that CEL string concatenation (+ operator) does not auto-cast to string. If you have a non-string scalar, use the string(<value>) function to cast the scalar to a string like shown in the

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Keep in mind that CEL string concatenation (+ operator) does not auto-cast to string. If you have a non-string scalar, use the string(<value>) function to cast the scalar to a string like shown in the


Prompt:
Explain this text code:

x-kubernetes-validations:
- rule: "self.x <= self.maxLimit"
  reason: "FieldValueInvalid"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The HTTP status code returned to the caller will match the reason of the first failed validation rule. The currently supported reasons are: "FieldValueInvalid", "FieldValueForbidden", "FieldValueRequi

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The HTTP status code returned to the caller will match the reason of the first failed validation rule. The currently supported reasons are: "FieldValueInvalid", "FieldValueForbidden", "FieldValueRequi


Prompt:
Explain this text code:

x-kubernetes-validations:
- rule: "self.foo.test.x <= self.maxLimit"
  fieldPath: ".foo.test.x"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | In the example above, the validation checks the value of field x should be less than the value of maxLimit. If no fieldPath specified, when validation fails, the fieldPath would be default to wherever

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | In the example above, the validation checks the value of field x should be less than the value of maxLimit. If no fieldPath specified, when validation fails, the fieldPath would be default to wherever


Prompt:
Complete this text code:

type: string
enum: ["low", "medium", "high"]

Response:
x-kubernetes-validations:
- rule: "!(self == 'high' && oldSelf == 'low') && !(self == 'low' && oldSelf == 'high')"
  message: cannot transition directly between 'low' and 'high'

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Unlike other rules, transition rules apply only to operations meeting the following criteria:


Prompt:
Explain this text code:

type: string
enum: ["low", "medium", "high"]
x-kubernetes-validations:
- rule: "!(self == 'high' && oldSelf == 'low') && !(self == 'low' && oldSelf == 'high')"
  message: cannot transition directly between 'low' and 'high'

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Unlike other rules, transition rules apply only to operations meeting the following criteria:


Prompt:
Complete this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:

Response:
      type: array
      items:
        type: string
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | then the API server rejects this rule on validation budget grounds with error:


Prompt:
Explain this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      items:
        type: string
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | then the API server rejects this rule on validation budget grounds with error:


Prompt:
Explain this text code:

spec.validation.openAPIV3Schema.properties[spec].properties[foo].x-kubernetes-validations[0].rule: Forbidden:
CEL rule exceeded budget by more than 100x (try simplifying the rule, or adding maxItems, maxProperties, and
maxLength where arrays, maps, and strings are used)

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The rejection happens because self.all implies calling contains() on every string in foo, which in turn will check the given string to see if it contains 'a string'. Without limits, this is a very exp

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The rejection happens because self.all implies calling contains() on every string in foo, which in turn will check the given string to see if it contains 'a string'. Without limits, this is a very exp


Prompt:
Complete this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array

Response:
      maxItems: 25
      items:
        type: string
        maxLength: 10
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The cost estimation system takes into account how many times the rule will be executed in addition to the estimated cost of the rule itself. For instance, the following rule will have the same estimat


Prompt:
Explain this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      maxItems: 25
      items:
        type: string
        maxLength: 10
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The cost estimation system takes into account how many times the rule will be executed in addition to the estimated cost of the rule itself. For instance, the following rule will have the same estimat


Prompt:
Complete this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array

Response:
      maxItems: 25
      items:
        type: string
        x-kubernetes-validations:
          - rule: "self.contains('a string'))"
        maxLength: 10

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If a list inside of a list has a validation rule that uses self.all, that is significantly more expensive than a non-nested list with the same rule. A rule that would have been allowed on a non-nested


Prompt:
Explain this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      maxItems: 25
      items:
        type: string
        x-kubernetes-validations:
          - rule: "self.contains('a string'))"
        maxLength: 10

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If a list inside of a list has a validation rule that uses self.all, that is significantly more expensive than a non-nested list with the same rule. A rule that would have been allowed on a non-nested


Prompt:
Complete this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:

Response:
      type: array
      items:
        type: integer
    x-kubernetes-validations:
      - rule: "self.all(x, x == 5)"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | But the same rule on the following schema (with a nested array added) produces a validation error:


Prompt:
Explain this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      items:
        type: integer
    x-kubernetes-validations:
      - rule: "self.all(x, x == 5)"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | But the same rule on the following schema (with a nested array added) produces a validation error:


Prompt:
Complete this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array

Response:
      items:
        type: array
        items:
          type: integer
        x-kubernetes-validations:
          - rule: "self.all(x, x == 5)"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This is because each item of foo is itself an array, and each subarray in turn calls self.all. Avoid nested lists and maps if possible where validation rules are used.


Prompt:
Explain this text code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      items:
        type: array
        items:
          type: integer
        x-kubernetes-validations:
          - rule: "self.all(x, x == 5)"

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This is because each item of foo is itself an array, and each subarray in turn calls self.all. Avoid nested lists and maps if possible where validation rules are used.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:

Response:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                  default: "5 0 * * *"
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this both cronSpec and replicas are defaulted:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                  default: "5 0 * * *"
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this both cronSpec and replicas are defaulted:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:

Response:
  name: my-new-cron-object
spec:
  image: my-awesome-cron-image

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | leads to


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | leads to


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "5 0 * * *"
  image: my-awesome-cron-image
  replicas: 1

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Defaulting happens on the object


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "5 0 * * *"
  image: my-awesome-cron-image
  replicas: 1

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Defaulting happens on the object


Prompt:
Complete this text code:

type: object
properties:
  spec:
    type: object
    properties:
      foo:
        type: string

Response:
        nullable: false
        default: "default"
      bar:
        type: string
        nullable: true
      baz:
        type: string

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | creating an object with null values for foo and bar and baz


Prompt:
Explain this text code:

type: object
properties:
  spec:
    type: object
    properties:
      foo:
        type: string
        nullable: false
        default: "default"
      bar:
        type: string
        nullable: true
      baz:
        type: string

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | creating an object with null values for foo and bar and baz


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:

Response:
          spec:
            type: object
            properties:
              cronSpec:
                type: string
              image:
                type: string
              replicas:
                type: integer
    additionalPrinterColumns:
    - name: Spec
      type: string
      description: The cron spec defining the interval a CronJob is run
      jsonPath: .spec.cronSpec
    - name: Replicas
      type: integer
      description: The number of jobs launched by the CronJob
      jsonPath: .spec.replicas
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              cronSpec:
                type: string
              image:
                type: string
              replicas:
                type: integer
    additionalPrinterColumns:
    - name: Spec
      type: string
      description: The cron spec defining the interval a CronJob is run
      jsonPath: .spec.cronSpec
    - name: Replicas
      type: integer
      description: The number of jobs launched by the CronJob
      jsonPath: .spec.replicas
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Explain this text code:

NAME                 SPEC        REPLICAS   AGE
my-new-cron-object   * * * * *   1          7s

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Each column includes a priority field. Currently, the priority differentiates between columns shown in standard view or wide view (using the -o wide flag).

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Each column includes a priority field. Currently, the priority differentiates between columns shown in standard view or wide view (using the -o wide flag).


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: shirts.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: shirts
    singular: shirt
    kind: Shirt
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object

Response:
        properties:
          spec:
            type: object
            properties:
              color:
                type: string
              size:
                type: string
    selectableFields:
    - jsonPath: .spec.color
    - jsonPath: .spec.size
    additionalPrinterColumns:
    - jsonPath: .spec.color
      name: Color
      type: string
    - jsonPath: .spec.size
      name: Size
      type: string


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: shirts.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: shirts
    singular: shirt
    kind: Shirt
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              color:
                type: string
              size:
                type: string
    selectableFields:
    - jsonPath: .spec.color
    - jsonPath: .spec.size
    additionalPrinterColumns:
    - jsonPath: .spec.color
      name: Color
      type: string
    - jsonPath: .spec.size
      name: Size
      type: string

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/customresourcedefinition/shirt-resource-definition.yaml

Response: This bash code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Define some Shirts by editing shirt-resources.yaml; for example:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Define some Shirts by editing shirt-resources.yaml; for example:


Prompt:
Complete this yaml code:

---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example1
spec:
  color: blue
  size: S
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:

Response:
  name: example2
spec:
  color: blue
  size: M
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example3
spec:
  color: green
  size: M

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the custom resources: