Prompt:
Complete this text code:

environment in (production, qa)
tier notin (frontend, backend)

Response:
partition
!partition

Context: Labels and Selectors | Similarly the comma separator acts as an AND operator. So filtering resources with a partition key (no matter the value) and with environment different than qa can be achieved using partition,environm


Prompt:
Explain this text code:

environment in (production, qa)
tier notin (frontend, backend)
partition
!partition

Response: This text code Labels and Selectors | Similarly the comma separator acts as an AND operator. So filtering resources with a partition key (no matter the value) and with environment different than qa can be achieved using partition,environm


Prompt:
Explain this bash code:

kubectl get pods -l environment=production,tier=frontend

Response: This bash code Labels and Selectors | or using set-based requirements:

Context: Labels and Selectors | or using set-based requirements:


Prompt:
Explain this bash code:

kubectl get pods -l 'environment in (production),tier in (frontend)'

Response: This bash code Labels and Selectors | As already mentioned set-based requirements are more expressive. For instance, they can implement the OR operator on values:

Context: Labels and Selectors | As already mentioned set-based requirements are more expressive. For instance, they can implement the OR operator on values:


Prompt:
Explain this bash code:

kubectl get pods -l 'environment in (production, qa)'

Response: This bash code Labels and Selectors | or restricting negative matching via notin operator:

Context: Labels and Selectors | or restricting negative matching via notin operator:


Prompt:
Explain this bash code:

kubectl get pods -l 'environment,environment notin (frontend)'

Response: This bash code Labels and Selectors | Some Kubernetes objects, such as services and replicationcontrollers, also use label selectors to specify sets of other resources, such as pods.

Context: Labels and Selectors | Some Kubernetes objects, such as services and replicationcontrollers, also use label selectors to specify sets of other resources, such as pods.


Prompt:
Complete this text code:

selector:
  matchLabels:
    component: redis

Response:
  matchExpressions:
    - { key: tier, operator: In, values: [cache] }
    - { key: environment, operator: NotIn, values: [dev] }

Context: Labels and Selectors | matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values a


Prompt:
Explain this text code:

selector:
  matchLabels:
    component: redis
  matchExpressions:
    - { key: tier, operator: In, values: [cache] }
    - { key: environment, operator: NotIn, values: [dev] }

Response: This text code Labels and Selectors | matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values a


Prompt:
Complete this text code:

labels:
  app: guestbook

Response:
  tier: backend
  role: master

Context: Labels and Selectors | and


Prompt:
Explain this text code:

labels:
  app: guestbook
  tier: backend
  role: master

Response: This text code Labels and Selectors | and

Context: Labels and Selectors | and


Prompt:
Complete this text code:

labels:
  app: guestbook

Response:
  tier: backend
  role: replica

Context: Labels and Selectors | The labels allow for slicing and dicing the resources along any dimension specified by a label:


Prompt:
Explain this text code:

labels:
  app: guestbook
  tier: backend
  role: replica

Response: This text code Labels and Selectors | The labels allow for slicing and dicing the resources along any dimension specified by a label:


Prompt:
Explain this bash code:

kubectl apply -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml
kubectl get pods -Lapp -Ltier -Lrole

Response: This bash code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten

Context: Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Complete this text code:

NAME                           READY  STATUS    RESTARTS   AGE   APP         TIER       ROLE
guestbook-fe-4nlpb             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-ght6d             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-jpy62             1/1    Running   0          1m    guestbook   frontend   <none>

Response:
guestbook-redis-master-5pg3b   1/1    Running   0          1m    guestbook   backend    master
guestbook-redis-replica-2q2yf  1/1    Running   0          1m    guestbook   backend    replica
guestbook-redis-replica-qgazl  1/1    Running   0          1m    guestbook   backend    replica
my-nginx-divi2                 1/1    Running   0          29m   nginx       <none>     <none>
my-nginx-o0ef1                 1/1    Running   0          29m   nginx       <none>     <none>


Prompt:
Explain this text code:

NAME                           READY  STATUS    RESTARTS   AGE   APP         TIER       ROLE
guestbook-fe-4nlpb             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-ght6d             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-jpy62             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-redis-master-5pg3b   1/1    Running   0          1m    guestbook   backend    master
guestbook-redis-replica-2q2yf  1/1    Running   0          1m    guestbook   backend    replica
guestbook-redis-replica-qgazl  1/1    Running   0          1m    guestbook   backend    replica
my-nginx-divi2                 1/1    Running   0          29m   nginx       <none>     <none>
my-nginx-o0ef1                 1/1    Running   0          29m   nginx       <none>     <none>

Response: This text code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Explain this text code:

NAME                           READY  STATUS   RESTARTS  AGE
guestbook-redis-replica-2q2yf  1/1    Running  0         3m
guestbook-redis-replica-qgazl  1/1    Running  0         3m

Response: This text code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Explain this text code:

pod/my-nginx-2035384211-j5fhi labeled
pod/my-nginx-2035384211-u2c7e labeled
pod/my-nginx-2035384211-u3t6x labeled

Response: This text code Labels and Selectors | This first filters all pods with the label "app=nginx", and then labels them with the "tier=fe". To see the pods you labeled, run:

Context: Labels and Selectors | This first filters all pods with the label "app=nginx", and then labels them with the "tier=fe". To see the pods you labeled, run:


Prompt:
Complete this text code:

NAME                        READY     STATUS    RESTARTS   AGE       TIER
my-nginx-2035384211-j5fhi   1/1       Running   0          23m       fe

Response:
my-nginx-2035384211-u2c7e   1/1       Running   0          23m       fe
my-nginx-2035384211-u3t6x   1/1       Running   0          23m       fe

Context: Labels and Selectors | This outputs all "app=nginx" pods, with an additional label column of pods' tier (specified with -L or --label-columns).


Prompt:
Explain this text code:

NAME                        READY     STATUS    RESTARTS   AGE       TIER
my-nginx-2035384211-j5fhi   1/1       Running   0          23m       fe
my-nginx-2035384211-u2c7e   1/1       Running   0          23m       fe
my-nginx-2035384211-u3t6x   1/1       Running   0          23m       fe

Response: This text code Labels and Selectors | This outputs all "app=nginx" pods, with an additional label column of pods' tier (specified with -L or --label-columns).


Prompt:
Complete this json code:

"metadata": {
  "labels": {
    "key1" : "value1",

Response:
    "key2" : "value2"
  }
}

Context: Labels and Selectors | Labels allow for efficient queries and watches and are ideal for use in UIs and CLIs. Non-identifying information should be recorded using annotations.


Prompt:
Explain this json code:

"metadata": {
  "labels": {
    "key1" : "value1",
    "key2" : "value2"
  }
}

Response: This json code Labels and Selectors | Labels allow for efficient queries and watches and are ideal for use in UIs and CLIs. Non-identifying information should be recorded using annotations.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: label-demo
  labels:
    environment: production

Response:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80

Context: Labels and Selectors | Unlike names and UIDs, labels do not provide uniqueness. In general, we expect many objects to carry the same label(s).


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: label-demo
  labels:
    environment: production
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80

Response: This yaml code Labels and Selectors | Unlike names and UIDs, labels do not provide uniqueness. In general, we expect many objects to carry the same label(s).


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: cuda-test
spec:
  containers:

Response:
    - name: cuda-test
      image: "registry.k8s.io/cuda-vector-add:v0.1"
      resources:
        limits:
          nvidia.com/gpu: 1
  nodeSelector:
    accelerator: nvidia-tesla-p100

Context: Labels and Selectors | Set-based label requirements allow filtering keys according to a set of values. Three kinds of operators are supported: in,notin and exists (only the key identifier). For example:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: cuda-test
spec:
  containers:
    - name: cuda-test
      image: "registry.k8s.io/cuda-vector-add:v0.1"
      resources:
        limits:
          nvidia.com/gpu: 1
  nodeSelector:
    accelerator: nvidia-tesla-p100

Response: This yaml code Labels and Selectors | Set-based label requirements allow filtering keys according to a set of values. Three kinds of operators are supported: in,notin and exists (only the key identifier). For example:


Prompt:
Complete this text code:

environment in (production, qa)
tier notin (frontend, backend)

Response:
partition
!partition


Prompt:
Explain this text code:

environment in (production, qa)
tier notin (frontend, backend)
partition
!partition

Response: This text code Labels and Selectors | Similarly the comma separator acts as an AND operator. So filtering resources with a partition key (no matter the value) and with environment different than qa can be achieved using partition,environm


Prompt:
Explain this text code:

partition in (customerA, customerB),environment!=qa

Response: This text code Labels and Selectors | For list and watch operations, you can specify label selectors to filter the sets of objects returned; you specify the filter using a query parameter. (To learn in detail about watches in Kubernetes,

Context: Labels and Selectors | For list and watch operations, you can specify label selectors to filter the sets of objects returned; you specify the filter using a query parameter. (To learn in detail about watches in Kubernetes,


Prompt:
Explain this text code:

?labelSelector=environment%3Dproduction,tier%3Dfrontend

Response: This text code Labels and Selectors | Both label selector styles can be used to list or watch resources via a REST client. For example, targeting apiserver with kubectl and using equality-based one may write:

Context: Labels and Selectors | Both label selector styles can be used to list or watch resources via a REST client. For example, targeting apiserver with kubectl and using equality-based one may write:


Prompt:
Explain this text code:

?labelSelector=environment+in+%28production%2Cqa%29%2Ctier+in+%28frontend%29

Response: This text code Labels and Selectors | Both label selector styles can be used to list or watch resources via a REST client. For example, targeting apiserver with kubectl and using equality-based one may write:


Prompt:
Explain this shell code:

kubectl get pods -l environment=production,tier=frontend

Response: This shell code Labels and Selectors | or using set-based requirements:


Prompt:
Explain this shell code:

kubectl get pods -l 'environment in (production),tier in (frontend)'

Response: This shell code Labels and Selectors | As already mentioned set-based requirements are more expressive. For instance, they can implement the OR operator on values:


Prompt:
Explain this shell code:

kubectl get pods -l 'environment in (production, qa)'

Response: This shell code Labels and Selectors | or restricting negative matching via notin operator:


Prompt:
Explain this shell code:

kubectl get pods -l 'environment,environment notin (frontend)'

Response: This shell code Labels and Selectors | Some Kubernetes objects, such as services and replicationcontrollers, also use label selectors to specify sets of other resources, such as pods.


Prompt:
Complete this yaml code:

selector:
  matchLabels:
    component: redis

Response:
  matchExpressions:
    - { key: tier, operator: In, values: [cache] }
    - { key: environment, operator: NotIn, values: [dev] }


Prompt:
Explain this yaml code:

selector:
  matchLabels:
    component: redis
  matchExpressions:
    - { key: tier, operator: In, values: [cache] }
    - { key: environment, operator: NotIn, values: [dev] }

Response: This yaml code Labels and Selectors | matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values a


Prompt:
Complete this yaml code:

labels:
  app: guestbook

Response:
  tier: backend
  role: master

Context: Labels and Selectors | and


Prompt:
Explain this yaml code:

labels:
  app: guestbook
  tier: backend
  role: master

Response: This yaml code Labels and Selectors | and

Context: Labels and Selectors | and


Prompt:
Complete this yaml code:

labels:
  app: guestbook

Response:
  tier: backend
  role: replica


Prompt:
Explain this yaml code:

labels:
  app: guestbook
  tier: backend
  role: replica

Response: This yaml code Labels and Selectors | The labels allow for slicing and dicing the resources along any dimension specified by a label:


Prompt:
Explain this shell code:

kubectl apply -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml
kubectl get pods -Lapp -Ltier -Lrole

Response: This shell code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Complete this none code:

NAME                           READY  STATUS    RESTARTS   AGE   APP         TIER       ROLE
guestbook-fe-4nlpb             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-ght6d             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-jpy62             1/1    Running   0          1m    guestbook   frontend   <none>

Response:
guestbook-redis-master-5pg3b   1/1    Running   0          1m    guestbook   backend    master
guestbook-redis-replica-2q2yf  1/1    Running   0          1m    guestbook   backend    replica
guestbook-redis-replica-qgazl  1/1    Running   0          1m    guestbook   backend    replica
my-nginx-divi2                 1/1    Running   0          29m   nginx       <none>     <none>
my-nginx-o0ef1                 1/1    Running   0          29m   nginx       <none>     <none>


Prompt:
Explain this none code:

NAME                           READY  STATUS    RESTARTS   AGE   APP         TIER       ROLE
guestbook-fe-4nlpb             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-ght6d             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-fe-jpy62             1/1    Running   0          1m    guestbook   frontend   <none>
guestbook-redis-master-5pg3b   1/1    Running   0          1m    guestbook   backend    master
guestbook-redis-replica-2q2yf  1/1    Running   0          1m    guestbook   backend    replica
guestbook-redis-replica-qgazl  1/1    Running   0          1m    guestbook   backend    replica
my-nginx-divi2                 1/1    Running   0          29m   nginx       <none>     <none>
my-nginx-o0ef1                 1/1    Running   0          29m   nginx       <none>     <none>

Response: This none code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Explain this none code:

NAME                           READY  STATUS   RESTARTS  AGE
guestbook-redis-replica-2q2yf  1/1    Running  0         3m
guestbook-redis-replica-qgazl  1/1    Running  0         3m

Response: This none code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Explain this none code:

pod/my-nginx-2035384211-j5fhi labeled
pod/my-nginx-2035384211-u2c7e labeled
pod/my-nginx-2035384211-u3t6x labeled

Response: This none code Labels and Selectors | This first filters all pods with the label "app=nginx", and then labels them with the "tier=fe". To see the pods you labeled, run:


Prompt:
Complete this none code:

NAME                        READY     STATUS    RESTARTS   AGE       TIER
my-nginx-2035384211-j5fhi   1/1       Running   0          23m       fe

Response:
my-nginx-2035384211-u2c7e   1/1       Running   0          23m       fe
my-nginx-2035384211-u3t6x   1/1       Running   0          23m       fe


Prompt:
Explain this none code:

NAME                        READY     STATUS    RESTARTS   AGE       TIER
my-nginx-2035384211-j5fhi   1/1       Running   0          23m       fe
my-nginx-2035384211-u2c7e   1/1       Running   0          23m       fe
my-nginx-2035384211-u3t6x   1/1       Running   0          23m       fe

Response: This none code Labels and Selectors | This outputs all "app=nginx" pods, with an additional label column of pods' tier (specified with -L or --label-columns).


Prompt:
Complete this text code:

"metadata": {
  "labels": {
    "key1" : "value1",

Response:
    "key2" : "value2"
  }
}


Prompt:
Explain this text code:

"metadata": {
  "labels": {
    "key1" : "value1",
    "key2" : "value2"
  }
}

Response: This text code Labels and Selectors | Labels allow for efficient queries and watches and are ideal for use in UIs and CLIs. Non-identifying information should be recorded using annotations.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: label-demo
  labels:
    environment: production

Response:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: label-demo
  labels:
    environment: production
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80

Response: This yaml code Labels and Selectors | Unlike names and UIDs, labels do not provide uniqueness. In general, we expect many objects to carry the same label(s).


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: cuda-test
spec:
  containers:

Response:
    - name: cuda-test
      image: "registry.k8s.io/cuda-vector-add:v0.1"
      resources:
        limits:
          nvidia.com/gpu: 1
  nodeSelector:
    accelerator: nvidia-tesla-p100


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Pod
metadata:
  name: cuda-test
spec:
  containers:
    - name: cuda-test
      image: "registry.k8s.io/cuda-vector-add:v0.1"
      resources:
        limits:
          nvidia.com/gpu: 1
  nodeSelector:
    accelerator: nvidia-tesla-p100

Response: This yaml code Labels and Selectors | Set-based label requirements allow filtering keys according to a set of values. Three kinds of operators are supported: in,notin and exists (only the key identifier). For example:


Prompt:
Explain this bash code:

kubectl get pods -l environment=production,tier=frontend

Response: This bash code Labels and Selectors | or using set-based requirements:


Prompt:
Explain this bash code:

kubectl get pods -l 'environment in (production),tier in (frontend)'

Response: This bash code Labels and Selectors | As already mentioned set-based requirements are more expressive. For instance, they can implement the OR operator on values:


Prompt:
Explain this bash code:

kubectl get pods -l 'environment in (production, qa)'

Response: This bash code Labels and Selectors | or restricting negative matching via notin operator:


Prompt:
Explain this bash code:

kubectl get pods -l 'environment,environment notin (frontend)'

Response: This bash code Labels and Selectors | Some Kubernetes objects, such as services and replicationcontrollers, also use label selectors to specify sets of other resources, such as pods.


Prompt:
Complete this text code:

selector:
  matchLabels:
    component: redis

Response:
  matchExpressions:
    - { key: tier, operator: In, values: [cache] }
    - { key: environment, operator: NotIn, values: [dev] }


Prompt:
Explain this text code:

selector:
  matchLabels:
    component: redis
  matchExpressions:
    - { key: tier, operator: In, values: [cache] }
    - { key: environment, operator: NotIn, values: [dev] }

Response: This text code Labels and Selectors | matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values a


Prompt:
Complete this text code:

labels:
  app: guestbook

Response:
  tier: backend
  role: master

Context: Labels and Selectors | and


Prompt:
Explain this text code:

labels:
  app: guestbook
  tier: backend
  role: master

Response: This text code Labels and Selectors | and

Context: Labels and Selectors | and


Prompt:
Complete this text code:

labels:
  app: guestbook

Response:
  tier: backend
  role: replica


Prompt:
Explain this text code:

labels:
  app: guestbook
  tier: backend
  role: replica

Response: This text code Labels and Selectors | The labels allow for slicing and dicing the resources along any dimension specified by a label:


Prompt:
Explain this bash code:

kubectl apply -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml
kubectl get pods -Lapp -Ltier -Lrole

Response: This bash code Labels and Selectors | Sometimes you may want to relabel existing pods and other resources before creating new resources. This can be done with kubectl label. For example, if you want to label all your NGINX Pods as fronten


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo

Response:
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"

Context: Configure Quotas for API Objects | Create the ResourceQuota:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"

Response: This yaml code Configure Quotas for API Objects | Create the ResourceQuota:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | View detailed information about the ResourceQuota:

Context: Configure Quotas for API Objects | View detailed information about the ResourceQuota:


Prompt:
Explain this bash code:

kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml

Response: This bash code Configure Quotas for API Objects | The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.

Context: Configure Quotas for API Objects | The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.


Prompt:
Complete this text code:

status:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"

Response:
    services.nodeports: "0"
  used:
    persistentvolumeclaims: "0"
    services.loadbalancers: "0"
    services.nodeports: "0"

Context: Configure Quotas for API Objects | Here is the configuration file for a PersistentVolumeClaim object:


Prompt:
Explain this text code:

status:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"
  used:
    persistentvolumeclaims: "0"
    services.loadbalancers: "0"
    services.nodeports: "0"

Response: This text code Configure Quotas for API Objects | Here is the configuration file for a PersistentVolumeClaim object:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

Context: Configure Quotas for API Objects | Create the PersistentVolumeClaim:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

Response: This yaml code Configure Quotas for API Objects | Create the PersistentVolumeClaim:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | Verify that the PersistentVolumeClaim was created:

Context: Configure Quotas for API Objects | Verify that the PersistentVolumeClaim was created:


Prompt:
Explain this bash code:

kubectl get persistentvolumeclaims --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | The output shows that the PersistentVolumeClaim exists and has status Pending:

Context: Configure Quotas for API Objects | The output shows that the PersistentVolumeClaim exists and has status Pending:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

Context: Configure Quotas for API Objects | Attempt to create the second PersistentVolumeClaim:


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

Response: This yaml code Configure Quotas for API Objects | Attempt to create the second PersistentVolumeClaim:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | The output shows that the second PersistentVolumeClaim was not created, because it would have exceeded the quota for the namespace.

Context: Configure Quotas for API Objects | The output shows that the second PersistentVolumeClaim was not created, because it would have exceeded the quota for the namespace.


Prompt:
Explain this text code:

persistentvolumeclaims "pvc-quota-demo-2" is forbidden:
exceeded quota: object-quota-demo, requested: persistentvolumeclaims=1,
used: persistentvolumeclaims=1, limited: persistentvolumeclaims=1

Response: This text code Configure Quotas for API Objects | These are the strings used to identify API resources that can be constrained by quotas:

Context: Configure Quotas for API Objects | These are the strings used to identify API resources that can be constrained by quotas:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo

Response:
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"

Response: This yaml code Configure Quotas for API Objects | Create the ResourceQuota:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example

Response: This shell code Configure Quotas for API Objects | View detailed information about the ResourceQuota:


Prompt:
Explain this shell code:

kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml

Response: This shell code Configure Quotas for API Objects | The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.


Prompt:
Complete this yaml code:

status:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"

Response:
    services.nodeports: "0"
  used:
    persistentvolumeclaims: "0"
    services.loadbalancers: "0"
    services.nodeports: "0"


Prompt:
Explain this yaml code:

status:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"
  used:
    persistentvolumeclaims: "0"
    services.loadbalancers: "0"
    services.nodeports: "0"

Response: This yaml code Configure Quotas for API Objects | Here is the configuration file for a PersistentVolumeClaim object:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

Response: This yaml code Configure Quotas for API Objects | Create the PersistentVolumeClaim:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example

Response: This shell code Configure Quotas for API Objects | Verify that the PersistentVolumeClaim was created:


Prompt:
Explain this shell code:

kubectl get persistentvolumeclaims --namespace=quota-object-example

Response: This shell code Configure Quotas for API Objects | The output shows that the PersistentVolumeClaim exists and has status Pending:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

Response: This yaml code Configure Quotas for API Objects | Attempt to create the second PersistentVolumeClaim:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=quota-object-example

Response: This shell code Configure Quotas for API Objects | The output shows that the second PersistentVolumeClaim was not created, because it would have exceeded the quota for the namespace.


Prompt:
Explain this text code:

persistentvolumeclaims "pvc-quota-demo-2" is forbidden:
exceeded quota: object-quota-demo, requested: persistentvolumeclaims=1,
used: persistentvolumeclaims=1, limited: persistentvolumeclaims=1

Response: This text code Configure Quotas for API Objects | These are the strings used to identify API resources that can be constrained by quotas:


Prompt:
Complete this yaml code:

admin/resource/quota-objects.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo

Response:
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"


Prompt:
Explain this yaml code:

admin/resource/quota-objects.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"

Response: This yaml code Configure Quotas for API Objects | Create the ResourceQuota:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo

Response:
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"


Prompt:
Explain this yaml code:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-quota-demo
spec:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"

Response: This yaml code Configure Quotas for API Objects | Create the ResourceQuota:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | View detailed information about the ResourceQuota:


Prompt:
Explain this bash code:

kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml

Response: This bash code Configure Quotas for API Objects | The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.


Prompt:
Complete this text code:

status:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"

Response:
    services.nodeports: "0"
  used:
    persistentvolumeclaims: "0"
    services.loadbalancers: "0"
    services.nodeports: "0"


Prompt:
Explain this text code:

status:
  hard:
    persistentvolumeclaims: "1"
    services.loadbalancers: "2"
    services.nodeports: "0"
  used:
    persistentvolumeclaims: "0"
    services.loadbalancers: "0"
    services.nodeports: "0"

Response: This text code Configure Quotas for API Objects | Here is the configuration file for a PersistentVolumeClaim object:


Prompt:
Complete this yaml code:

admin/resource/quota-objects-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi


Prompt:
Explain this yaml code:

admin/resource/quota-objects-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

Response: This yaml code Configure Quotas for API Objects | Create the PersistentVolumeClaim:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

Response: This yaml code Configure Quotas for API Objects | Create the PersistentVolumeClaim:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | Verify that the PersistentVolumeClaim was created:


Prompt:
Explain this bash code:

kubectl get persistentvolumeclaims --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | The output shows that the PersistentVolumeClaim exists and has status Pending:


Prompt:
Complete this yaml code:

admin/resource/quota-objects-pvc-2.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi


Prompt:
Explain this yaml code:

admin/resource/quota-objects-pvc-2.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

Response: This yaml code Configure Quotas for API Objects | Attempt to create the second PersistentVolumeClaim:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:

Response:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi


Prompt:
Explain this yaml code:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-quota-demo-2
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

Response: This yaml code Configure Quotas for API Objects | Attempt to create the second PersistentVolumeClaim:


Prompt:
Explain this bash code:

kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=quota-object-example

Response: This bash code Configure Quotas for API Objects | The output shows that the second PersistentVolumeClaim was not created, because it would have exceeded the quota for the namespace.


Prompt:
Explain this bash code:

kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh

Response: This bash code Debug Services | If you already have a running Pod that you prefer to use, you can run a command in it using:

Context: Debug Services | If you already have a running Pod that you prefer to use, you can run a command in it using:


Prompt:
Explain this bash code:

kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>

Response: This bash code Debug Services | For the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.

Context: Debug Services | For the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.


Prompt:
Explain this bash code:

kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname

Response: This bash code Debug Services | kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.

Context: Debug Services | kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.


Prompt:
Complete this yaml code:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:

Response:
      app: hostnames
  replicas: 3
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: registry.k8s.io/serve_hostname

Context: Debug Services | The label "app" is automatically set by kubectl create deployment to the name of the Deployment.


Prompt:
Explain this yaml code:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:
      app: hostnames
  replicas: 3
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: registry.k8s.io/serve_hostname

Response: This yaml code Debug Services | The label "app" is automatically set by kubectl create deployment to the name of the Deployment.


Prompt:
Complete this text code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          2m

Response:
hostnames-632524106-ly40y   1/1       Running   0          2m
hostnames-632524106-tlaok   1/1       Running   0          2m

Context: Debug Services | You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.


Prompt:
Explain this text code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          2m
hostnames-632524106-ly40y   1/1       Running   0          2m
hostnames-632524106-tlaok   1/1       Running   0          2m

Response: This text code Debug Services | You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.


Prompt:
Explain this bash code:

kubectl get pods -l app=hostnames \
    -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}'

Response: This bash code Debug Services | The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening o

Context: Debug Services | The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening o


Prompt:
Explain this text code:

for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do
    wget -qO- $ep
done

Response: This text code Debug Services | This should produce something like:

Context: Debug Services | This should produce something like:


Prompt:
Explain this text code:

hostnames-632524106-bbpiw
hostnames-632524106-ly40y
hostnames-632524106-tlaok

Response: This text code Debug Services | If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for see

Context: Debug Services | If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for see


Prompt:
Explain this text code:

Resolving hostnames (hostnames)... failed: Name or service not known.
wget: unable to resolve host address 'hostnames'

Response: This text code Debug Services | The first thing to check is whether that Service actually exists:

Context: Debug Services | The first thing to check is whether that Service actually exists:


Prompt:
Explain this text code:

No resources found.
Error from server (NotFound): services "hostnames" not found

Response: This text code Debug Services | Let's create the Service. As before, this is for the walk-through - you can use your own Service's details here.

Context: Debug Services | Let's create the Service. As before, this is for the walk-through - you can use your own Service's details here.


Prompt:
Explain this bash code:

kubectl expose deployment hostnames --port=80 --target-port=9376

Response: This bash code Debug Services | And read it back:

Context: Debug Services | And read it back:


Prompt:
Explain this text code:

NAME        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
hostnames   ClusterIP   10.0.1.175   <none>        80/TCP    5s

Response: This text code Debug Services | Now you know that the Service exists.

Context: Debug Services | Now you know that the Service exists.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:

Response:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

Context: Debug Services | In order to highlight the full range of configuration, the Service you created here uses a different port number than the Pods. For many real-world Services, these values might be the same.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

Response: This yaml code Debug Services | In order to highlight the full range of configuration, the Service you created here uses a different port number than the Pods. For many real-world Services, these values might be the same.


Prompt:
Complete this text code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      hostnames
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Context: Debug Services | If this fails, perhaps your Pod and Service are in different Namespaces, try a namespace-qualified name (again, from within a Pod):


Prompt:
Explain this text code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      hostnames
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Response: This text code Debug Services | If this fails, perhaps your Pod and Service are in different Namespaces, try a namespace-qualified name (again, from within a Pod):


Prompt:
Complete this text code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      hostnames.default
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Context: Debug Services | If this works, you'll need to adjust your app to use a cross-namespace name, or run your app and Service in the same Namespace. If this still fails, try a fully-qualified name:


Prompt:
Explain this text code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      hostnames.default
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Response: This text code Debug Services | If this works, you'll need to adjust your app to use a cross-namespace name, or run your app and Service in the same Namespace. If this still fails, try a fully-qualified name:


Prompt:
Complete this text code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      hostnames.default.svc.cluster.local
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Context: Debug Services | Note the suffix here: "default.svc.cluster.local". The "default" is the Namespace you're operating in. The "svc" denotes that this is a Service. The "cluster.local" is your cluster domain, which COULD


Prompt:
Explain this text code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      hostnames.default.svc.cluster.local
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Response: This text code Debug Services | Note the suffix here: "default.svc.cluster.local". The "default" is the Namespace you're operating in. The "svc" denotes that this is a Service. The "cluster.local" is your cluster domain, which COULD


Prompt:
Explain this text code:

nslookup hostnames.default.svc.cluster.local 10.0.0.10

Response: This text code Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:

Context: Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:


Prompt:
Complete this text code:

Server:         10.0.0.10
Address:        10.0.0.10#53

Response:
Name:   hostnames.default.svc.cluster.local
Address: 10.0.1.175


Prompt:
Explain this text code:

Server:         10.0.0.10
Address:        10.0.0.10#53

Name:   hostnames.default.svc.cluster.local
Address: 10.0.1.175

Response: This text code Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:


Prompt:
Explain this text code:

nameserver 10.0.0.10
search default.svc.cluster.local svc.cluster.local cluster.local example.com
options ndots:5

Response: This text code Debug Services | The nameserver line must indicate your cluster's DNS Service. This is passed into kubelet with the --cluster-dns flag.

Context: Debug Services | The nameserver line must indicate your cluster's DNS Service. This is passed into kubelet with the --cluster-dns flag.


Prompt:
Complete this text code:

Server:    10.0.0.10
Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      kubernetes.default
Address 1: 10.0.0.1 kubernetes.default.svc.cluster.local

Context: Debug Services | If this fails, please see the kube-proxy section of this document, or even go back to the top of this document and start over, but instead of debugging your own Service, debug the DNS Service.


Prompt:
Explain this text code:

Server:    10.0.0.10
Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes.default
Address 1: 10.0.0.1 kubernetes.default.svc.cluster.local

Response: This text code Debug Services | If this fails, please see the kube-proxy section of this document, or even go back to the top of this document and start over, but instead of debugging your own Service, debug the DNS Service.


Prompt:
Explain this text code:

for i in $(seq 1 3); do
    wget -qO- 10.0.1.175:80
done

Response: This text code Debug Services | This should produce something like:


Prompt:
Explain this text code:

hostnames-632524106-bbpiw
hostnames-632524106-ly40y
hostnames-632524106-tlaok

Response: This text code Debug Services | If your Service is working, you should get correct responses. If not, there are a number of things that could be going wrong. Read on.

Context: Debug Services | If your Service is working, you should get correct responses. If not, there are a number of things that could be going wrong. Read on.


Prompt:
Complete this json code:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "hostnames",
        "namespace": "default",
        "uid": "428c8b6c-24bc-11e5-936d-42010af0a9bc",
        "resourceVersion": "347189",
        "creationTimestamp": "2015-07-07T15:24:29Z",
        "labels": {
            "app": "hostnames"
        }
    },
    "spec": {
        "ports": [
            {
                "name": "default",

Response:
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376,
                "nodePort": 0
            }
        ],
        "selector": {
            "app": "hostnames"
        },
        "clusterIP": "10.0.1.175",
        "type": "ClusterIP",
        "sessionAffinity": "None"
    },
    "status": {
        "loadBalancer": {}
    }
}

Context: Debug Services | If you got this far, you have confirmed that your Service is correctly defined and is resolved by DNS. Now let's check that the Pods you ran are actually being selected by the Service.


Prompt:
Explain this json code:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "hostnames",
        "namespace": "default",
        "uid": "428c8b6c-24bc-11e5-936d-42010af0a9bc",
        "resourceVersion": "347189",
        "creationTimestamp": "2015-07-07T15:24:29Z",
        "labels": {
            "app": "hostnames"
        }
    },
    "spec": {
        "ports": [
            {
                "name": "default",
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376,
                "nodePort": 0
            }
        ],
        "selector": {
            "app": "hostnames"
        },
        "clusterIP": "10.0.1.175",
        "type": "ClusterIP",
        "sessionAffinity": "None"
    },
    "status": {
        "loadBalancer": {}
    }
}

Response: This json code Debug Services | If you got this far, you have confirmed that your Service is correctly defined and is resolved by DNS. Now let's check that the Pods you ran are actually being selected by the Service.


Prompt:
Complete this text code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          1h

Response:
hostnames-632524106-ly40y   1/1       Running   0          1h
hostnames-632524106-tlaok   1/1       Running   0          1h

Context: Debug Services | The -l app=hostnames argument is a label selector configured on the Service.


Prompt:
Explain this text code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          1h
hostnames-632524106-ly40y   1/1       Running   0          1h
hostnames-632524106-tlaok   1/1       Running   0          1h

Response: This text code Debug Services | The -l app=hostnames argument is a label selector configured on the Service.


Prompt:
Complete this bash code:

kubectl get endpointslices -l k8s.io/service-name=hostnames

Response:
NAME              ADDRESSTYPE   PORTS   ENDPOINTS
hostnames-ytpni   IPv4          9376    10.244.0.5,10.244.0.6,10.244.0.7

Context: Debug Services | This confirms that the EndpointSlice controller has found the correct Pods for your Service. If the ENDPOINTS column is <none>, you should check that the spec.selector field of your Service actually s


Prompt:
Explain this bash code:

kubectl get endpointslices -l k8s.io/service-name=hostnames

NAME              ADDRESSTYPE   PORTS   ENDPOINTS
hostnames-ytpni   IPv4          9376    10.244.0.5,10.244.0.6,10.244.0.7

Response: This bash code Debug Services | This confirms that the EndpointSlice controller has found the correct Pods for your Service. If the ENDPOINTS column is <none>, you should check that the spec.selector field of your Service actually s


Prompt:
Explain this text code:

for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do
    wget -qO- $ep
done

Response: This text code Debug Services | This should produce something like:


Prompt:
Explain this text code:

hostnames-632524106-bbpiw
hostnames-632524106-ly40y
hostnames-632524106-tlaok

Response: This text code Debug Services | You expect each Pod in the endpoints list to return its own hostname. If this is not what happens (or whatever the correct behavior is for your own Pods), you should investigate what's happening there

Context: Debug Services | You expect each Pod in the endpoints list to return its own hostname. If this is not what happens (or whatever the correct behavior is for your own Pods), you should investigate what's happening there


Prompt:
Explain this text code:

root  4194  0.4  0.1 101864 17696 ?    Sl Jul04  25:43 /usr/local/bin/kube-proxy --master=https://kubernetes-master --kubeconfig=/var/lib/kube-proxy/kubeconfig --v=2

Response: This text code Debug Services | Next, confirm that it is not failing something obvious, like contacting the master. To do this, you'll have to look at the logs. Accessing the logs depends on your Node OS. On some OSes it is a file,

Context: Debug Services | Next, confirm that it is not failing something obvious, like contacting the master. To do this, you'll have to look at the logs. Accessing the logs depends on your Node OS. On some OSes it is a file,


Prompt:
Complete this text code:

I1027 22:14:53.995134    5063 server.go:200] Running in resource-only container "/kube-proxy"
I1027 22:14:53.998163    5063 server.go:247] Using iptables Proxier.
I1027 22:14:54.038140    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns-tcp" to [10.244.1.3:53]
I1027 22:14:54.038164    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns" to [10.244.1.3:53]

Response:
I1027 22:14:54.038209    5063 proxier.go:352] Setting endpoints for "default/kubernetes:https" to [10.240.0.2:443]
I1027 22:14:54.038238    5063 proxier.go:429] Not syncing iptables until Services and Endpoints have been received from master
I1027 22:14:54.040048    5063 proxier.go:294] Adding new service "default/kubernetes:https" at 10.0.0.1:443/TCP
I1027 22:14:54.040154    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns" at 10.0.0.10:53/UDP
I1027 22:14:54.040223    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns-tcp" at 10.0.0.10:53/TCP

Context: Debug Services | If you see error messages about not being able to contact the master, you should double-check your Node configuration and installation steps.


Prompt:
Explain this text code:

I1027 22:14:53.995134    5063 server.go:200] Running in resource-only container "/kube-proxy"
I1027 22:14:53.998163    5063 server.go:247] Using iptables Proxier.
I1027 22:14:54.038140    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns-tcp" to [10.244.1.3:53]
I1027 22:14:54.038164    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns" to [10.244.1.3:53]
I1027 22:14:54.038209    5063 proxier.go:352] Setting endpoints for "default/kubernetes:https" to [10.240.0.2:443]
I1027 22:14:54.038238    5063 proxier.go:429] Not syncing iptables until Services and Endpoints have been received from master
I1027 22:14:54.040048    5063 proxier.go:294] Adding new service "default/kubernetes:https" at 10.0.0.1:443/TCP
I1027 22:14:54.040154    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns" at 10.0.0.10:53/UDP
I1027 22:14:54.040223    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns-tcp" at 10.0.0.10:53/TCP

Response: This text code Debug Services | If you see error messages about not being able to contact the master, you should double-check your Node configuration and installation steps.


Prompt:
Complete this text code:

-A KUBE-SEP-57KPRZ3JQVENLNBR -s 10.244.3.6/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-57KPRZ3JQVENLNBR -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.3.6:9376
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -s 10.244.1.7/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.1.7:9376
-A KUBE-SEP-X3P2623AGDH6CDF3 -s 10.244.2.3/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000

Response:
-A KUBE-SEP-X3P2623AGDH6CDF3 -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.2.3:9376
-A KUBE-SERVICES -d 10.0.1.175/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-SVC-NWV5X2332I4OT4T3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-WNBA2IHDGP2BOBGZ
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-X3P2623AGDH6CDF3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -j KUBE-SEP-57KPRZ3JQVENLNBR

Context: Debug Services | For each port of each Service, there should be 1 rule in KUBE-SERVICES and one KUBE-SVC-<hash> chain. For each Pod endpoint, there should be a small number of rules in that KUBE-SVC-<hash> and one KUB


Prompt:
Explain this text code:

-A KUBE-SEP-57KPRZ3JQVENLNBR -s 10.244.3.6/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-57KPRZ3JQVENLNBR -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.3.6:9376
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -s 10.244.1.7/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.1.7:9376
-A KUBE-SEP-X3P2623AGDH6CDF3 -s 10.244.2.3/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-X3P2623AGDH6CDF3 -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.2.3:9376
-A KUBE-SERVICES -d 10.0.1.175/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-SVC-NWV5X2332I4OT4T3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-WNBA2IHDGP2BOBGZ
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-X3P2623AGDH6CDF3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -j KUBE-SEP-57KPRZ3JQVENLNBR

Response: This text code Debug Services | For each port of each Service, there should be 1 rule in KUBE-SERVICES and one KUBE-SVC-<hash> chain. For each Pod endpoint, there should be a small number of rules in that KUBE-SVC-<hash> and one KUB


Prompt:
Complete this text code:

Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
...
TCP  10.0.1.175:80 rr

Response:
  -> 10.244.0.5:9376               Masq    1      0          0
  -> 10.244.0.6:9376               Masq    1      0          0
  -> 10.244.0.7:9376               Masq    1      0          0
...

Context: Debug Services | For each port of each Service, plus any NodePorts, external IPs, and load-balancer IPs, kube-proxy will create a virtual server. For each Pod endpoint, it will create corresponding real servers. In th


Prompt:
Explain this text code:

Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
...
TCP  10.0.1.175:80 rr
  -> 10.244.0.5:9376               Masq    1      0          0
  -> 10.244.0.6:9376               Masq    1      0          0
  -> 10.244.0.7:9376               Masq    1      0          0
...

Response: This text code Debug Services | For each port of each Service, plus any NodePorts, external IPs, and load-balancer IPs, kube-proxy will create a virtual server. For each Pod endpoint, it will create corresponding real servers. In th


Prompt:
Explain this text code:

Setting endpoints for default/hostnames:default to [10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376]

Response: This text code Debug Services | If you don't see those, try restarting kube-proxy with the -v flag set to 4, and then look at the logs again.

Context: Debug Services | If you don't see those, try restarting kube-proxy with the -v flag set to 4, and then look at the logs again.


Prompt:
Explain this text code:

root      3392  1.1  0.8 186804 65208 ?        Sl   00:51  11:11 /usr/local/bin/kubelet --enable-debugging-handlers=true --config=/etc/kubernetes/manifests --allow-privileged=True --v=4 --cluster-dns=10.0.0.10 --cluster-domain=cluster.local --configure-cbr0=true --cgroup-root=/ --system-cgroups=/system --hairpin-mode=promiscuous-bridge --runtime-cgroups=/docker-daemon --kubelet-cgroups=/kubelet --babysit-daemons=true --max-pods=110 --serialize-image-pulls=false --outofdisk-transition-frequency=0

Response: This text code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb

Context: Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this text code:

I0629 00:51:43.648698    3252 kubelet.go:380] Hairpin mode set to "promiscuous-bridge"

Response: This text code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this text code:

for intf in /sys/devices/virtual/net/cbr0/brif/*; do cat $intf/hairpin_mode; done

Response: This text code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this text code:

UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1460  Metric:1

Response: This text code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this none code:

kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh

Response: This none code Debug Services | If you already have a running Pod that you prefer to use, you can run a command in it using:

Context: Debug Services | If you already have a running Pod that you prefer to use, you can run a command in it using:


Prompt:
Explain this shell code:

kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>

Response: This shell code Debug Services | For the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.

Context: Debug Services | For the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.


Prompt:
Explain this shell code:

kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname

Response: This shell code Debug Services | kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.

Context: Debug Services | kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.


Prompt:
Complete this yaml code:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:

Response:
      app: hostnames
  replicas: 3
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: registry.k8s.io/serve_hostname

Context: Debug Services | The label "app" is automatically set by kubectl create deployment to the name of the Deployment.


Prompt:
Explain this yaml code:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:
      app: hostnames
  replicas: 3
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: registry.k8s.io/serve_hostname

Response: This yaml code Debug Services | The label "app" is automatically set by kubectl create deployment to the name of the Deployment.


Prompt:
Complete this none code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          2m

Response:
hostnames-632524106-ly40y   1/1       Running   0          2m
hostnames-632524106-tlaok   1/1       Running   0          2m

Context: Debug Services | You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.


Prompt:
Explain this none code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          2m
hostnames-632524106-ly40y   1/1       Running   0          2m
hostnames-632524106-tlaok   1/1       Running   0          2m

Response: This none code Debug Services | You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.


Prompt:
Explain this shell code:

kubectl get pods -l app=hostnames \
    -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}'

Response: This shell code Debug Services | The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening o

Context: Debug Services | The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening o


Prompt:
Explain this shell code:

for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do
    wget -qO- $ep
done

Response: This shell code Debug Services | This should produce something like:

Context: Debug Services | This should produce something like:


Prompt:
Explain this text code:

hostnames-632524106-bbpiw
hostnames-632524106-ly40y
hostnames-632524106-tlaok

Response: This text code Debug Services | If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for see

Context: Debug Services | If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for see


Prompt:
Explain this none code:

Resolving hostnames (hostnames)... failed: Name or service not known.
wget: unable to resolve host address 'hostnames'

Response: This none code Debug Services | The first thing to check is whether that Service actually exists:

Context: Debug Services | The first thing to check is whether that Service actually exists:


Prompt:
Explain this none code:

No resources found.
Error from server (NotFound): services "hostnames" not found

Response: This none code Debug Services | Let's create the Service. As before, this is for the walk-through - you can use your own Service's details here.

Context: Debug Services | Let's create the Service. As before, this is for the walk-through - you can use your own Service's details here.


Prompt:
Explain this shell code:

kubectl expose deployment hostnames --port=80 --target-port=9376

Response: This shell code Debug Services | And read it back:

Context: Debug Services | And read it back:


Prompt:
Explain this none code:

NAME        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
hostnames   ClusterIP   10.0.1.175   <none>        80/TCP    5s

Response: This none code Debug Services | Now you know that the Service exists.

Context: Debug Services | Now you know that the Service exists.


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:

Response:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

Context: Debug Services | In order to highlight the full range of configuration, the Service you created here uses a different port number than the Pods. For many real-world Services, these values might be the same.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

Response: This yaml code Debug Services | In order to highlight the full range of configuration, the Service you created here uses a different port number than the Pods. For many real-world Services, these values might be the same.


Prompt:
Complete this none code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      hostnames
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Context: Debug Services | If this fails, perhaps your Pod and Service are in different Namespaces, try a namespace-qualified name (again, from within a Pod):


Prompt:
Explain this none code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      hostnames
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Response: This none code Debug Services | If this fails, perhaps your Pod and Service are in different Namespaces, try a namespace-qualified name (again, from within a Pod):


Prompt:
Complete this none code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      hostnames.default
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Context: Debug Services | If this works, you'll need to adjust your app to use a cross-namespace name, or run your app and Service in the same Namespace. If this still fails, try a fully-qualified name:


Prompt:
Explain this none code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      hostnames.default
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Response: This none code Debug Services | If this works, you'll need to adjust your app to use a cross-namespace name, or run your app and Service in the same Namespace. If this still fails, try a fully-qualified name:


Prompt:
Complete this none code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      hostnames.default.svc.cluster.local
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Context: Debug Services | Note the suffix here: "default.svc.cluster.local". The "default" is the Namespace you're operating in. The "svc" denotes that this is a Service. The "cluster.local" is your cluster domain, which COULD


Prompt:
Explain this none code:

Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      hostnames.default.svc.cluster.local
Address 1: 10.0.1.175 hostnames.default.svc.cluster.local

Response: This none code Debug Services | Note the suffix here: "default.svc.cluster.local". The "default" is the Namespace you're operating in. The "svc" denotes that this is a Service. The "cluster.local" is your cluster domain, which COULD


Prompt:
Explain this shell code:

nslookup hostnames.default.svc.cluster.local 10.0.0.10

Response: This shell code Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:

Context: Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:


Prompt:
Complete this none code:

Server:         10.0.0.10
Address:        10.0.0.10#53

Response:
Name:   hostnames.default.svc.cluster.local
Address: 10.0.1.175


Prompt:
Explain this none code:

Server:         10.0.0.10
Address:        10.0.0.10#53

Name:   hostnames.default.svc.cluster.local
Address: 10.0.1.175

Response: This none code Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:


Prompt:
Explain this text code:

nameserver 10.0.0.10
search default.svc.cluster.local svc.cluster.local cluster.local example.com
options ndots:5

Response: This text code Debug Services | The nameserver line must indicate your cluster's DNS Service. This is passed into kubelet with the --cluster-dns flag.

Context: Debug Services | The nameserver line must indicate your cluster's DNS Service. This is passed into kubelet with the --cluster-dns flag.


Prompt:
Complete this none code:

Server:    10.0.0.10
Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Response:
Name:      kubernetes.default
Address 1: 10.0.0.1 kubernetes.default.svc.cluster.local

Context: Debug Services | If this fails, please see the kube-proxy section of this document, or even go back to the top of this document and start over, but instead of debugging your own Service, debug the DNS Service.


Prompt:
Explain this none code:

Server:    10.0.0.10
Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes.default
Address 1: 10.0.0.1 kubernetes.default.svc.cluster.local

Response: This none code Debug Services | If this fails, please see the kube-proxy section of this document, or even go back to the top of this document and start over, but instead of debugging your own Service, debug the DNS Service.


Prompt:
Explain this shell code:

for i in $(seq 1 3); do
    wget -qO- 10.0.1.175:80
done

Response: This shell code Debug Services | This should produce something like:


Prompt:
Explain this text code:

hostnames-632524106-bbpiw
hostnames-632524106-ly40y
hostnames-632524106-tlaok

Response: This text code Debug Services | If your Service is working, you should get correct responses. If not, there are a number of things that could be going wrong. Read on.

Context: Debug Services | If your Service is working, you should get correct responses. If not, there are a number of things that could be going wrong. Read on.


Prompt:
Complete this json code:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "hostnames",
        "namespace": "default",
        "uid": "428c8b6c-24bc-11e5-936d-42010af0a9bc",
        "resourceVersion": "347189",
        "creationTimestamp": "2015-07-07T15:24:29Z",
        "labels": {
            "app": "hostnames"
        }
    },
    "spec": {
        "ports": [
            {
                "name": "default",

Response:
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376,
                "nodePort": 0
            }
        ],
        "selector": {
            "app": "hostnames"
        },
        "clusterIP": "10.0.1.175",
        "type": "ClusterIP",
        "sessionAffinity": "None"
    },
    "status": {
        "loadBalancer": {}
    }
}

Context: Debug Services | If you got this far, you have confirmed that your Service is correctly defined and is resolved by DNS. Now let's check that the Pods you ran are actually being selected by the Service.


Prompt:
Explain this json code:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "hostnames",
        "namespace": "default",
        "uid": "428c8b6c-24bc-11e5-936d-42010af0a9bc",
        "resourceVersion": "347189",
        "creationTimestamp": "2015-07-07T15:24:29Z",
        "labels": {
            "app": "hostnames"
        }
    },
    "spec": {
        "ports": [
            {
                "name": "default",
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376,
                "nodePort": 0
            }
        ],
        "selector": {
            "app": "hostnames"
        },
        "clusterIP": "10.0.1.175",
        "type": "ClusterIP",
        "sessionAffinity": "None"
    },
    "status": {
        "loadBalancer": {}
    }
}

Response: This json code Debug Services | If you got this far, you have confirmed that your Service is correctly defined and is resolved by DNS. Now let's check that the Pods you ran are actually being selected by the Service.


Prompt:
Complete this none code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          1h

Response:
hostnames-632524106-ly40y   1/1       Running   0          1h
hostnames-632524106-tlaok   1/1       Running   0          1h

Context: Debug Services | The -l app=hostnames argument is a label selector configured on the Service.


Prompt:
Explain this none code:

NAME                        READY     STATUS    RESTARTS   AGE
hostnames-632524106-bbpiw   1/1       Running   0          1h
hostnames-632524106-ly40y   1/1       Running   0          1h
hostnames-632524106-tlaok   1/1       Running   0          1h

Response: This none code Debug Services | The -l app=hostnames argument is a label selector configured on the Service.


Prompt:
Complete this shell code:

kubectl get endpointslices -l k8s.io/service-name=hostnames

Response:
NAME              ADDRESSTYPE   PORTS   ENDPOINTS
hostnames-ytpni   IPv4          9376    10.244.0.5,10.244.0.6,10.244.0.7

Context: Debug Services | This confirms that the EndpointSlice controller has found the correct Pods for your Service. If the ENDPOINTS column is <none>, you should check that the spec.selector field of your Service actually s


Prompt:
Explain this shell code:

kubectl get endpointslices -l k8s.io/service-name=hostnames

NAME              ADDRESSTYPE   PORTS   ENDPOINTS
hostnames-ytpni   IPv4          9376    10.244.0.5,10.244.0.6,10.244.0.7

Response: This shell code Debug Services | This confirms that the EndpointSlice controller has found the correct Pods for your Service. If the ENDPOINTS column is <none>, you should check that the spec.selector field of your Service actually s


Prompt:
Explain this shell code:

for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do
    wget -qO- $ep
done

Response: This shell code Debug Services | This should produce something like:


Prompt:
Explain this text code:

hostnames-632524106-bbpiw
hostnames-632524106-ly40y
hostnames-632524106-tlaok

Response: This text code Debug Services | You expect each Pod in the endpoints list to return its own hostname. If this is not what happens (or whatever the correct behavior is for your own Pods), you should investigate what's happening there

Context: Debug Services | You expect each Pod in the endpoints list to return its own hostname. If this is not what happens (or whatever the correct behavior is for your own Pods), you should investigate what's happening there


Prompt:
Explain this none code:

root  4194  0.4  0.1 101864 17696 ?    Sl Jul04  25:43 /usr/local/bin/kube-proxy --master=https://kubernetes-master --kubeconfig=/var/lib/kube-proxy/kubeconfig --v=2

Response: This none code Debug Services | Next, confirm that it is not failing something obvious, like contacting the master. To do this, you'll have to look at the logs. Accessing the logs depends on your Node OS. On some OSes it is a file,

Context: Debug Services | Next, confirm that it is not failing something obvious, like contacting the master. To do this, you'll have to look at the logs. Accessing the logs depends on your Node OS. On some OSes it is a file,


Prompt:
Complete this none code:

I1027 22:14:53.995134    5063 server.go:200] Running in resource-only container "/kube-proxy"
I1027 22:14:53.998163    5063 server.go:247] Using iptables Proxier.
I1027 22:14:54.038140    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns-tcp" to [10.244.1.3:53]
I1027 22:14:54.038164    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns" to [10.244.1.3:53]

Response:
I1027 22:14:54.038209    5063 proxier.go:352] Setting endpoints for "default/kubernetes:https" to [10.240.0.2:443]
I1027 22:14:54.038238    5063 proxier.go:429] Not syncing iptables until Services and Endpoints have been received from master
I1027 22:14:54.040048    5063 proxier.go:294] Adding new service "default/kubernetes:https" at 10.0.0.1:443/TCP
I1027 22:14:54.040154    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns" at 10.0.0.10:53/UDP
I1027 22:14:54.040223    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns-tcp" at 10.0.0.10:53/TCP

Context: Debug Services | If you see error messages about not being able to contact the master, you should double-check your Node configuration and installation steps.


Prompt:
Explain this none code:

I1027 22:14:53.995134    5063 server.go:200] Running in resource-only container "/kube-proxy"
I1027 22:14:53.998163    5063 server.go:247] Using iptables Proxier.
I1027 22:14:54.038140    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns-tcp" to [10.244.1.3:53]
I1027 22:14:54.038164    5063 proxier.go:352] Setting endpoints for "kube-system/kube-dns:dns" to [10.244.1.3:53]
I1027 22:14:54.038209    5063 proxier.go:352] Setting endpoints for "default/kubernetes:https" to [10.240.0.2:443]
I1027 22:14:54.038238    5063 proxier.go:429] Not syncing iptables until Services and Endpoints have been received from master
I1027 22:14:54.040048    5063 proxier.go:294] Adding new service "default/kubernetes:https" at 10.0.0.1:443/TCP
I1027 22:14:54.040154    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns" at 10.0.0.10:53/UDP
I1027 22:14:54.040223    5063 proxier.go:294] Adding new service "kube-system/kube-dns:dns-tcp" at 10.0.0.10:53/TCP

Response: This none code Debug Services | If you see error messages about not being able to contact the master, you should double-check your Node configuration and installation steps.


Prompt:
Complete this none code:

-A KUBE-SEP-57KPRZ3JQVENLNBR -s 10.244.3.6/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-57KPRZ3JQVENLNBR -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.3.6:9376
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -s 10.244.1.7/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.1.7:9376
-A KUBE-SEP-X3P2623AGDH6CDF3 -s 10.244.2.3/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000

Response:
-A KUBE-SEP-X3P2623AGDH6CDF3 -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.2.3:9376
-A KUBE-SERVICES -d 10.0.1.175/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-SVC-NWV5X2332I4OT4T3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-WNBA2IHDGP2BOBGZ
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-X3P2623AGDH6CDF3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -j KUBE-SEP-57KPRZ3JQVENLNBR

Context: Debug Services | For each port of each Service, there should be 1 rule in KUBE-SERVICES and one KUBE-SVC-<hash> chain. For each Pod endpoint, there should be a small number of rules in that KUBE-SVC-<hash> and one KUB


Prompt:
Explain this none code:

-A KUBE-SEP-57KPRZ3JQVENLNBR -s 10.244.3.6/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-57KPRZ3JQVENLNBR -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.3.6:9376
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -s 10.244.1.7/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-WNBA2IHDGP2BOBGZ -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.1.7:9376
-A KUBE-SEP-X3P2623AGDH6CDF3 -s 10.244.2.3/32 -m comment --comment "default/hostnames:" -j MARK --set-xmark 0x00004000/0x00004000
-A KUBE-SEP-X3P2623AGDH6CDF3 -p tcp -m comment --comment "default/hostnames:" -m tcp -j DNAT --to-destination 10.244.2.3:9376
-A KUBE-SERVICES -d 10.0.1.175/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-SVC-NWV5X2332I4OT4T3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-WNBA2IHDGP2BOBGZ
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-X3P2623AGDH6CDF3
-A KUBE-SVC-NWV5X2332I4OT4T3 -m comment --comment "default/hostnames:" -j KUBE-SEP-57KPRZ3JQVENLNBR

Response: This none code Debug Services | For each port of each Service, there should be 1 rule in KUBE-SERVICES and one KUBE-SVC-<hash> chain. For each Pod endpoint, there should be a small number of rules in that KUBE-SVC-<hash> and one KUB


Prompt:
Complete this none code:

Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
...
TCP  10.0.1.175:80 rr

Response:
  -> 10.244.0.5:9376               Masq    1      0          0
  -> 10.244.0.6:9376               Masq    1      0          0
  -> 10.244.0.7:9376               Masq    1      0          0
...

Context: Debug Services | For each port of each Service, plus any NodePorts, external IPs, and load-balancer IPs, kube-proxy will create a virtual server. For each Pod endpoint, it will create corresponding real servers. In th


Prompt:
Explain this none code:

Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
...
TCP  10.0.1.175:80 rr
  -> 10.244.0.5:9376               Masq    1      0          0
  -> 10.244.0.6:9376               Masq    1      0          0
  -> 10.244.0.7:9376               Masq    1      0          0
...

Response: This none code Debug Services | For each port of each Service, plus any NodePorts, external IPs, and load-balancer IPs, kube-proxy will create a virtual server. For each Pod endpoint, it will create corresponding real servers. In th


Prompt:
Explain this none code:

Setting endpoints for default/hostnames:default to [10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376]

Response: This none code Debug Services | If you don't see those, try restarting kube-proxy with the -v flag set to 4, and then look at the logs again.

Context: Debug Services | If you don't see those, try restarting kube-proxy with the -v flag set to 4, and then look at the logs again.


Prompt:
Explain this none code:

root      3392  1.1  0.8 186804 65208 ?        Sl   00:51  11:11 /usr/local/bin/kubelet --enable-debugging-handlers=true --config=/etc/kubernetes/manifests --allow-privileged=True --v=4 --cluster-dns=10.0.0.10 --cluster-domain=cluster.local --configure-cbr0=true --cgroup-root=/ --system-cgroups=/system --hairpin-mode=promiscuous-bridge --runtime-cgroups=/docker-daemon --kubelet-cgroups=/kubelet --babysit-daemons=true --max-pods=110 --serialize-image-pulls=false --outofdisk-transition-frequency=0

Response: This none code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb

Context: Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this none code:

I0629 00:51:43.648698    3252 kubelet.go:380] Hairpin mode set to "promiscuous-bridge"

Response: This none code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this shell code:

for intf in /sys/devices/virtual/net/cbr0/brif/*; do cat $intf/hairpin_mode; done

Response: This shell code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this none code:

UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1460  Metric:1

Response: This none code Debug Services | If you get this far, something very strange is happening. Your Service is running, has EndpointSlices, and your Pods are actually serving. You have DNS working, and kube-proxy does not seem to be misb


Prompt:
Explain this bash code:

kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>

Response: This bash code Debug Services | For the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.

Context: Debug Services | For the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.


Prompt:
Explain this bash code:

kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname

Response: This bash code Debug Services | kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.

Context: Debug Services | kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.


Prompt:
Complete this yaml code:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:

Response:
      app: hostnames
  replicas: 3
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: registry.k8s.io/serve_hostname

Context: Debug Services | The label "app" is automatically set by kubectl create deployment to the name of the Deployment.


Prompt:
Explain this yaml code:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:
      app: hostnames
  replicas: 3
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: registry.k8s.io/serve_hostname

Response: This yaml code Debug Services | The label "app" is automatically set by kubectl create deployment to the name of the Deployment.


Prompt:
Explain this bash code:

kubectl get pods -l app=hostnames \
    -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}'

Response: This bash code Debug Services | The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening o

Context: Debug Services | The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening o


Prompt:
Explain this text code:

for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do
    wget -qO- $ep
done

Response: This text code Debug Services | This should produce something like:

Context: Debug Services | This should produce something like:


Prompt:
Explain this bash code:

kubectl expose deployment hostnames --port=80 --target-port=9376

Response: This bash code Debug Services | And read it back:

Context: Debug Services | And read it back:


Prompt:
Complete this yaml code:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:

Response:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

Context: Debug Services | In order to highlight the full range of configuration, the Service you created here uses a different port number than the Pods. For many real-world Services, these values might be the same.


Prompt:
Explain this yaml code:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

Response: This yaml code Debug Services | In order to highlight the full range of configuration, the Service you created here uses a different port number than the Pods. For many real-world Services, these values might be the same.


Prompt:
Explain this text code:

nslookup hostnames.default.svc.cluster.local 10.0.0.10

Response: This text code Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:

Context: Debug Services | If you are able to do a fully-qualified name lookup but not a relative one, you need to check that your /etc/resolv.conf file in your Pod is correct. From within a Pod:


Prompt:
Explain this text code:

for i in $(seq 1 3); do
    wget -qO- 10.0.1.175:80
done

Response: This text code Debug Services | This should produce something like:


Prompt:
Complete this json code:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "hostnames",
        "namespace": "default",
        "uid": "428c8b6c-24bc-11e5-936d-42010af0a9bc",
        "resourceVersion": "347189",
        "creationTimestamp": "2015-07-07T15:24:29Z",
        "labels": {
            "app": "hostnames"
        }
    },
    "spec": {
        "ports": [
            {
                "name": "default",

Response:
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376,
                "nodePort": 0
            }
        ],
        "selector": {
            "app": "hostnames"
        },
        "clusterIP": "10.0.1.175",
        "type": "ClusterIP",
        "sessionAffinity": "None"
    },
    "status": {
        "loadBalancer": {}
    }
}

Context: Debug Services | If you got this far, you have confirmed that your Service is correctly defined and is resolved by DNS. Now let's check that the Pods you ran are actually being selected by the Service.


Prompt:
Explain this json code:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "hostnames",
        "namespace": "default",
        "uid": "428c8b6c-24bc-11e5-936d-42010af0a9bc",
        "resourceVersion": "347189",
        "creationTimestamp": "2015-07-07T15:24:29Z",
        "labels": {
            "app": "hostnames"
        }
    },
    "spec": {
        "ports": [
            {
                "name": "default",
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376,
                "nodePort": 0
            }
        ],
        "selector": {
            "app": "hostnames"
        },
        "clusterIP": "10.0.1.175",
        "type": "ClusterIP",
        "sessionAffinity": "None"
    },
    "status": {
        "loadBalancer": {}
    }
}

Response: This json code Debug Services | If you got this far, you have confirmed that your Service is correctly defined and is resolved by DNS. Now let's check that the Pods you ran are actually being selected by the Service.


Prompt:
Complete this bash code:

kubectl get endpointslices -l k8s.io/service-name=hostnames

Response:
NAME              ADDRESSTYPE   PORTS   ENDPOINTS
hostnames-ytpni   IPv4          9376    10.244.0.5,10.244.0.6,10.244.0.7