0% found this document useful (0 votes)
46 views28 pages

K8S Field TechNotes

The document discusses creating and managing a pod in Kubernetes. It shows creating a pod manifest file, deploying the pod, and using kubectl commands to view pod information and events. It notes that pods are not typically used directly in production and that replication controllers provide a higher level, declarative approach to managing replicated pods.

Uploaded by

Thomas Kraus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views28 pages

K8S Field TechNotes

The document discusses creating and managing a pod in Kubernetes. It shows creating a pod manifest file, deploying the pod, and using kubectl commands to view pod information and events. It notes that pods are not typically used directly in production and that replication controllers provide a higher level, declarative approach to managing replicated pods.

Uploaded by

Thomas Kraus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

LAB Exercises -

1. POD’s

Script started on Tue Sep 12 10:45:20 2017


sh-3.2# ls
pod-practice-1.yml pods-rcs-services-practice-log.log

sh-3.2# vi pod-practice-1.yml
apiVersion: v1
kind: Pod
metadata:
name: hello-pod
spec:
containers:
- name: hello-ctr
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080

sh-3.2# kubectl create -f pod-practice-1.yml


pod "hello-pod" created
sh-3.2# kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-pod 1/1 Running 0 2m

sh-3.2# kubectl get pods


sh-3.2# kubectl describe pods
Name: hello-pod
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 10:46:52 -0400
Labels: <none>
Annotations: <none>
Status: Running
IP: 172.17.0.4
Containers:
hello-ctr:
Container ID: docker://755addac7a390c79a6d0d04b409bc3640943d84213e0491a097d6682d9cd1f50
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 10:46:53 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath
Type Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
2m 2m 1 default-scheduler Normal
Scheduled Successfully assigned hello-pod to minikube
2m 2m 1 kubelet, minikube Normal
SuccessfulMountVolume MountVolume.SetUp succeeded for volume "default-token-gdkd3"
2m 2m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Pulling pulling image "nigelpoulton/pluralsight-docker-ci:latest"
2m 2m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Pulled Successfully pulled image "nigelpoulton/pluralsight-docker-ci:latest"
2m 2m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Created Created container
2m 2m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Started Started container

sh-3.2# kubectl describe pods/hello-world


Name: hello-pod
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 10:46:52 -0400
Labels: <none>
Annotations: <none>
Status: Running
IP: 172.17.0.4
Containers:
hello-ctr:
Container ID: docker://755addac7a390c79a6d0d04b409bc3640943d84213e0491a097d6682d9cd1f50
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 10:46:53 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath
Type Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
3m 3m 1 default-scheduler Normal
Scheduled Successfully assigned hello-pod to minikube
3m 3m 1 kubelet, minikube Normal
SuccessfulMountVolume MountVolume.SetUp succeeded for volume "default-token-gdkd3"
3m 3m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Pulling pulling image "nigelpoulton/pluralsight-docker-ci:latest"
3m 3m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Pulled Successfully pulled image "nigelpoulton/pluralsight-docker-ci:latest"
3m 3m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Created Created container
3m 3m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Started Started container

ssh-3.2# kubectl get pods/hello-world


NAME READY STATUS RESTARTS AGE
hello-pod 1/1 Running 0 4m

sh-3.2# kubectl describe pods/hello-pod


Name: hello-pod
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 10:46:52 -0400
Labels: <none>
Annotations: <none>
Status: Running
IP: 172.17.0.4
Containers:
hello-ctr:
Container ID: docker://755addac7a390c79a6d0d04b409bc3640943d84213e0491a097d6682d9cd1f50
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 10:46:53 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath
Type Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
4m 4m 1 default-scheduler Normal
Scheduled Successfully assigned hello-pod to minikube
4m 4m 1 kubelet, minikube Normal
SuccessfulMountVolume MountVolume.SetUp succeeded for volume "default-token-gdkd3"
4m 4m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Pulling pulling image "nigelpoulton/pluralsight-docker-ci:latest"
4m 4m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Pulled Successfully pulled image "nigelpoulton/pluralsight-docker-ci:latest"
4m 4m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Created Created container
4m 4m 1 kubelet, minikube spec.containers{hello-ctr} Normal
Started Started container

sh-3.2# kubectl describe pods --all-namespaces


NAMESPACE NAME READY STATUS RESTARTS AGE
default hello-pod 1/1 Running 0 5m
kube-system kube-addon-manager-minikube 1/1 Running 2 19h
kube-system kube-dns-910330662-jtzhx 3/3 Running 6 19h
kube-system kubernetes-dashboard-580rd 1/1 Running 2 19h

NOTE - Will not usually work with PODS like this - because it is imperative
NOTE - We will use Replication Controllers/ Services as they are higher level and
DECLARATIVE.

sh-3.2# pwd
/Users/t/gitHub/kubernetes-work/Pods
sh-3.2# ls
pod-practice-1.yml pods-rcs-services-practice-log.log

sh-3.2# cd ../Replication-Controller/
sh-3.2# kubectl delete pod hello-pod
pod "hello-pod" deleted

1. REPLICATION CONTROLLERS - DECLARATIVE


a. Superceded by Replica Sets and Deployments

sh-3.2# cat rc.yml


kind: ReplicationController
metadata:
name: hello-rc
spec:
replicas: 10
selector:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080

kubectl create -f rc.yml


"hello-rc" created

NOTE: Spacing matters for YAML files - Use 2 Spaces (Not tabs) (Characters) for each new
level.

sh-3.2# kubectl describe replication-controllers hello-rc


Name: hello-rc
Namespace: default
Selector:app=hello-world
Labels: app=hello-world
Annotations: <none>
Replicas: 10 current / 10 desired
Pods Status: 10 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=hello-world
Containers:
hello-pod:
Image: nigelpoulton/pluralsight-docker-ci:latest
Port: 8080/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-h8t8g
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-00mtq
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-kbf08
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-xs968
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-vlrc3
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-jxwsr
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-709wb
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-fh0ps
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-1gl91
3m 3m 1 replication-controller Normal
SuccessfulCreate (combined from similar events): Created pod: hello-rc-20rm3
sh-3.2# kubectl describe rc[K[K[K[K[K[K[K[K[K[K[Kget rc
NAME DESIRED CURRENT READY AGE
hello-rc 10 10 10 3m
sh-3.2# kubectl get rc[1Prc[1Prc[1Prc[1Prcdrcercsrccrc[Crcircbrcerc rc[C[C/hello-rc
Name: hello-rc
Namespace: default
Selector:app=hello-world
Labels: app=hello-world
Annotations: <none>
Replicas: 10 current / 10 desired
Pods Status: 10 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=hello-world
Containers:
hello-pod:
Image: nigelpoulton/pluralsight-docker-ci:latest
Port: 8080/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-h8t8g
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-00mtq
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-kbf08
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-xs968
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-vlrc3
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-jxwsr
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-709wb
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-fh0ps
3m 3m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-1gl91
3m 3m 1 replication-controller Normal
SuccessfulCreate (combined from similar events): Created pod: hello-rc-20rm3

Updating RC’s

sh-3.2# vi rc.yml
kind: ReplicationController
metadata:
name: hello-rc
spec:
replicas: 20
selector:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080

lsh-3.2# kubectl apply -f rc.yml


Warning: kubectl apply should be used on resource created by either kubectl create
--save-config or kubectl apply
replicationcontroller "hello-rc" configured
lsh-3.2# kubectl describe rc/hello-rc
Name: hello-rc
Namespace: default
Selector:app=hello-world
Labels: app=hello-world
Annotations:
kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"ReplicationController","metadata":
{"annotations":{},"name":"hello-rc","namespace":"default"},"spec":{"replicas":20,"selector...
Replicas: 20 current / 20 desired
Pods Status: 13 Running / 7 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=hello-world
Containers:
hello-pod:
Image: nigelpoulton/pluralsight-docker-ci:latest
Port: 8080/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-h8t8g
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-00mtq
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-kbf08
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-xs968
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-vlrc3
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-jxwsr
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-709wb
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-fh0ps
4m 4m 1 replication-controller Normal
SuccessfulCreate Created pod: hello-rc-1gl91
4m 8s 11 replication-controller Normal
SuccessfulCreate (combined from similar events): Created pod: hello-rc-zrzc5

SECTION - SERVICES
sh-3.2# kubectl get nodes
NAME STATUS AGE VERSION
minikube Ready 19h v1.7.5

sh-3.2# kubectl describe node/minikube

Name: minikube
Role:
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/hostname=minikube
Annotations: alpha.kubernetes.io/provided-node-ip=192.168.64.3
node.alpha.kubernetes.io/ttl=0
volumes.kubernetes.io/controller-managed-attach-detach=true
Taints: <none>
CreationTimestamp: Mon, 11 Sep 2017 15:14:13 -0400
Conditions:
Type Status LastHeartbeatTime LastTransitionTime
Reason Message
---- ------ ----------------- ------------------
------ -------
OutOfDisk False Tue, 12 Sep 2017 11:08:40 -0400 Mon, 11 Sep 2017 15:14:13 -0400
KubeletHasSufficientDisk kubelet has sufficient disk space available
MemoryPressure False Tue, 12 Sep 2017 11:08:40 -0400 Mon, 11 Sep 2017 15:14:13 -0400
KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False Tue, 12 Sep 2017 11:08:40 -0400 Mon, 11 Sep 2017 15:14:13 -0400
KubeletHasNoDiskPressure kubelet has no disk pressure
Ready True Tue, 12 Sep 2017 11:08:40 -0400 Mon, 11 Sep 2017 15:14:24 -0400
KubeletReady kubelet is posting ready status
Addresses:
InternalIP: 192.168.64.3
Hostname: minikube
Capacity:
cpu: 2
memory: 2048148Ki
pods: 110
Allocatable:
cpu: 2
memory: 1945748Ki
pods: 110
System Info:
Machine ID: b84ddb9d9157491c9c1bcc5a1a37b08e
System UUID: 882741A6-0000-0000-BB88-2847BA1880E6
Boot ID: 9eef9b9e-b4d9-4dbb-8270-ef80b7af470f
Kernel Version: 4.9.13
OS Image: Buildroot 2017.02
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://1.12.6
Kubelet Version: v1.7.5
Kube-Proxy Version: v1.7.5
ExternalID: minikube
Non-terminated Pods: (23 in total)
Namespace Name CPU Requests CPU
Limits Memory Requests Memory Limits
--------- ---- ---------------------- ---------------
-------------
default hello-rc-00mtq 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-0385w 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-054gn 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-1gl91 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-1v3cr 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-20rm3 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-709wb 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-910qv 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-fh0ps 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-gg3sx 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-h0ghv 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-h8t8g 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-jxwsr 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-kbf08 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-q16mk 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-s4bkf 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-vlrc3 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-xs968 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-zlh77 0 (0%) 0 (0%)
0 (0%) 0 (0%)
default hello-rc-zrzc5 0 (0%) 0 (0%)
0 (0%) 0 (0%)
kube-system kube-addon-manager-minikube 5m (0%) 0 (0%)
50Mi (2%) 0 (0%)
kube-system kube-dns-910330662-jtzhx 260m (13%) 0 (0%)
110Mi (5%) 170Mi (8%)
kube-system kubernetes-dashboard-580rd 0 (0%) 0 (0%)
0 (0%) 0 (0%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
CPU Requests CPU Limits Memory Requests Memory Limits
------------ ---------- --------------- -------------
265m (13%) 0 (0%) 160Mi (8%) 170Mi (8%)
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
30m 30m 1 kubelet, minikube Normal Starting
Starting kubelet.
30m 30m 1 kubelet, minikube Normal
NodeAllocatableEnforced Updated Node Allocatable limit across pods
30m 30m 1 kubelet, minikube Normal
NodeHasSufficientDisk Node minikube status is now: NodeHasSufficientDisk
30m 30m 1 kubelet, minikube Normal
NodeHasSufficientMemory Node minikube status is now: NodeHasSufficientMemory
30m 30m 1 kubelet, minikube Normal
NodeHasNoDiskPressure Node minikube status is now: NodeHasNoDiskPressure
30m 30m 1 kubelet, minikube Warning
Rebooted Node minikube has been rebooted, boot id:
9eef9b9e-b4d9-4dbb-8270-ef80b7af470f
30m 30m 1 kube-proxy, minikube Normal
Starting Starting kube-proxy.

sh-3.2# kubectl expose rc hello-rc --name=hello-svc --target-port=8080 --type=NodePort


service "hello-svc" exposed

sh-3.2# kubectl describe svc hello-svc


Name: hello-svc
Namespace: default
Labels: app=hello-world
Annotations: <none>
Selector: app=hello-world
Type: NodePort
IP: 10.0.0.13
Port: <unset> 8080/TCP
NodePort: <unset> 32685/TCP
Endpoints: 172.17.0.10:8080,172.17.0.11:8080,172.17.0.12:8080 + 17
more...
Session Affinity: None
Events: <none>

NOTE: Using IP Address of Master (Its a Single Node cluster (Node and Master) are combined
192.168.64.3:32685. IT works from Chrome
NOTE: Service Ports will by default be between 32,000 and 32,767.

NOTE: This was iterative - Not Kubernetes way.

NOTE: NOW We will Create Service Declaratively with YAML file.

sh-3.2# kubectl delete svc hello-svc


service "hello-svc" deleted

sh-3.2# vi Services/service.yml
apiVersion: v1
kind: Service
metadata:
name: hello-svc
labels:
app: hello-world
spec:
type: NodePort
ports:
- port: 8080
protocol: TCP
selector:
app: hello-world

NOTE::
1. ClusterIP - (Default) Gets a stable IP within the CLUSTER ONLY.
2. NodePort - Exposes app externally by adding a Service Port for the Service. Assigned
random port above 30000 then Service Port for access
3. LocalBalancer - Intergrates NodePort with CloudBased Load Balancers

sh-3.2# kubectl create -f Services/service.yml

sh-3.2# vi Services/service-2.yml
apiVersion: v1
kind: Service
metadata:
name: hello-svc
labels:
app: hello-world
spec:
type: NodePort
ports:
- port: 8080
nodePort: 30001
protocol: TCP
selector:
app: hello-world

sh-3.2# kubectl create -f Services/service-2.yml

NOTE: You can also specify the nodePort (or it can be assigned dynamically).

sh-3.2# kubectl describe pods


Labels: app=hello-world
Labels: app=hello-world
Labels: app=hello-world

Labels: app=hello-world
Labels: app=hello-world
Labels: app=hello-world
Labels: app=hello-world

NOTE: this will be used when deploying the Service for the selector: app: hello-world selector
label to match to.

sh-3.2# kubectl get services


service "hello-svc" created

NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE


hello-svc 10.0.0.125 <nodes> 8080:30001/TCP 5s
kubernetes 10.0.0.1 <none> 443/TCP 21h

sh-3.2# kubectl describe services/hello-svc

Name: hello-svc
Namespace: default
Labels: app=hello-world
Annotations: <none>
Selector: app=hello-world
Type: NodePort
IP: 10.0.0.125
Port: <unset> 8080/TCP
NodePort: <unset> 30001/TCP
Endpoints: 172.17.0.10:8080,172.17.0.11:8080,172.17.0.12:8080 + 17 more...
Session Affinity: None
Events: <none>

sh-3.2# kubectl describe pods

Name: hello-rc-00mtq
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 11:00:33 -0400
Labels: app=hello-world
Annotations:
kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationCon
troller","namespace":"default","name":"hello-rc","uid":"202034a9-97cb-11e7-9456-3a18bf0e81eb...
Status: Running
IP: 172.17.0.5
Created By: ReplicationController/hello-rc
Controlled By: ReplicationController/hello-rc
Containers:
hello-pod:
Container ID: docker://1261b69d38948543f258dddc14ce0b64c7afbe888b3eef5311e74afadcc74b7e
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 11:00:35 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events: <none>
Name: hello-rc-0385w
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 11:05:13 -0400
Labels: app=hello-world
Annotations:
kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationCon
troller","namespace":"default","name":"hello-rc","uid":"202034a9-97cb-11e7-9456-3a18bf0e81eb...
Status: Running
IP: 172.17.0.16
Created By: ReplicationController/hello-rc
Controlled By: ReplicationController/hello-rc
Containers:
hello-pod:
Container ID: docker://d2031b7637f1d3783cb93f86f9c0f2475b81837f736daf536813ca686474a146
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 11:05:16 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events: <none>

Name: hello-rc-054gn
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 11:05:13 -0400
Labels: app=hello-world
Annotations:
kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationCon
troller","namespace":"default","name":"hello-rc","uid":"202034a9-97cb-11e7-9456-3a18bf0e81eb...
Status: Running
IP: 172.17.0.14
Created By: ReplicationController/hello-rc
Controlled By: ReplicationController/hello-rc
Containers:
hello-pod:
Container ID: docker://13d256552b516f627d1eba86a38e9d0662bcbb820602db36a851fb0851cc9018
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 11:05:15 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events: <none>

Name: hello-rc-1gl91
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 11:00:33 -0400
Labels: app=hello-world
Annotations:
kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationCon
troller","namespace":"default","name":"hello-rc","uid":"202034a9-97cb-11e7-9456-3a18bf0e81eb...
Status: Running
IP: 172.17.0.4
Created By: ReplicationController/hello-rc
Controlled By: ReplicationController/hello-rc
Containers:
hello-pod:
Container ID: docker://a7317682c1fcf655c89b71d4e333030adb5103ee4794955ec74b271ddc7d8c2b
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
Name: hello-rc-20rm3
Namespace: default
Node: minikube/192.168.64.3
Start Time: Tue, 12 Sep 2017 11:00:33 -0400
Labels: app=hello-world
Annotations:
kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationCon
troller","namespace":"default","name":"hello-rc","uid":"202034a9-97cb-11e7-9456-3a18bf0e81eb...
Status: Running
IP: 172.17.0.13
Created By: ReplicationController/hello-rc
Controlled By: ReplicationController/hello-rc
Containers:
hello-pod:
Container ID: docker://b17575ea7aaf176691885b4f4ec87416d0b6b493948d690fd36c6b68b2ae1a1c
Image: nigelpoulton/pluralsight-docker-ci:latest
Image ID:
docker-pullable://nigelpoulton/pluralsight-docker-ci@sha256:7a6b0125fe7893e70dc63b2c42ad779e5866c6
d2779ceb9b12a28e2c38bd8d3d
Port: 8080/TCP
State: Running
Started: Tue, 12 Sep 2017 11:00:39 -0400
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-gdkd3 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-gdkd3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-gdkd3
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events: <none>

sh-3.2# kubectl describe svc --all-namespaces


Port: https 443/TCP
Endpoints: 192.168.64.3:8443
Session Affinity: ClientIP
Events: <none>

Name: kube-dns
Namespace: kube-system
Labels: addonmanager.kubernetes.io/mode=Reconcile
k8s-app=kube-dns
kubernetes.io/name=KubeDNS
Annotations:
kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"
annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"Reconcile","k8s-app":"kube-dns",
"kubernet...
Selector: k8s-app=kube-dns
Type: ClusterIP
IP: 10.0.0.10
Port: dns 53/UDP
Endpoints: 172.17.0.2:53Name: hello-svc
Namespace: default
Labels: app=hello-world
Annotations: <none>
Selector: app=hello-world
Type: NodePort
IP: 10.0.0.125
Port: <unset> 8080/TCP
NodePort: <unset> 30001/TCP
Endpoints: 172.17.0.10:8080,172.17.0.11:8080,172.17.0.12:8080 + 17 more...
Session Affinity: None
Events: <none>

Name: kubernetes
Namespace: default
Labels: component=apiserver
provider=kubernetes
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP: 10.0.0.1

Port: dns-tcp 53/TCP


Endpoints: 172.17.0.2:53
Session Affinity: None
Events: <none>
Name: kubernetes-dashboard
Namespace: kube-system
Labels: addonmanager.kubernetes.io/mode=Reconcile
app=kubernetes-dashboard
kubernetes.io/minikube-addons=dashboard
kubernetes.io/minikube-addons-endpoint=dashboard
Annotations:
kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations
":{},"labels":{"addonmanager.kubernetes.io/mode":"Reconcile","app":"kubernetes-dashboard","...
Selector: app=kubernetes-dashboard
Type: NodePort
IP: 10.0.0.16
Port: <unset> 80/TCP
NodePort: <unset> 30000/TCP
Endpoints: 172.17.0.3:9090
Session Affinity: None
Events: <none>

NOTE: TO FIND OUT THE Dashboard IP Address

sh-3.2# kubectl describe pods --all-namespaces --selector=app=kubernetes-dashboard


NOTE: Then access via the NODE IP and the : NodePort - 192.168.64.3:30000

NOTE: I hit 192;.168.64.3:30001 in browser and it worked great. Took some time
sh: Took: command not found

sh-3.2# kubectl get ep


NAME ENDPOINTS AGE
hello-svc 172.17.0.10:8080,172.17.0.11:8080,172.17.0.12:8080 + 17 more... 24m
kubernetes 192.168.64.3:8443 21h
sh-3.2# kubectl get ep[K[K[K[K[K[Kdescribe ep hello-svc
Name: hello-svc
Namespace: default
Labels: app=hello-world
Annotations: <none>
Subsets:
Addresses:
172.17.0.10,172.17.0.11,172.17.0.12,172.17.0.13,172.17.0.14,172.17.0.15,172.17.0.16,172.17.0.17,172.17.
0.18,172.17.0.19,172.17.0.20,172.17.0.21,172.17.0.22,172.17.0.23,172.17.0.4,172.17.0.5,172.17.0.6,172.1
7.0.7,172.17.0.8,172.17.0.9
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
<unset> 8080 TCP
Events: <none>

Updating Apps and Services using Labels

Deployments

Script started on Wed Sep 13 11:55:42 2017

bash-3.2$ pwd
/Users/user/gitHub/kubernetes-work

bash-3.2$ kubectl delete rc hello-rc

bash-3.2$ kubectl describe svc hello-svc


Name: hello-svc
Namespace: default
Labels: app=hello-world
Annotations: <none>
Selector: app=hello-world
Type: NodePort
IP: 10.0.0.125
Port: <unset> 8080/TCP
NodePort: <unset> 30001/TCP
Endpoints: <none>
Session Affinity: None
Events: <none>

bash-3.2$ edit Deployments/deployment.yml


apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-deploy
spec:
replicas: 10
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080

bash-3.2$ kubectl create -f Deployments/deployment.yml


deployment "hello-deploy" created

bash-3.2$ kubectl describe deploy hello-deploy


Name: hello-deploy
Namespace: default
CreationTimestamp: Wed, 13 Sep 2017 11:58:37 -0400
Labels: app=hello-world
Annotations: deployment.kubernetes.io/revision=1
Selector: app=hello-world
Replicas: 10 desired | 10 updated | 10 total | 10 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 1 max unavailable, 1 max surge
Pod Template:
Labels: app=hello-world
Containers:
hello-pod:
Image: nigelpoulton/pluralsight-docker-ci:latest
Port: 8080/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
OldReplicaSets: <none>
NewReplicaSet: hello-deploy-2512326018 (10/10 replicas created)
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
<invalid> <invalid> 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2512326018 to 10

NOTE: Also checked in Web Kubernetes Dashboard - 192.168.64.3:30000 under


Deployments. I could Edit and Update the Configuration - Change Repli
cas etc. . . .

bash-3.2$ kubectl describe deploy hello-deploy

Name: hello-deploy
Namespace: default
CreationTimestamp: Wed, 13 Sep 2017 11:58:37 -0400
Labels: app=hello-world
Annotations: deployment.kubernetes.io/revision=1
Selector: app=hello-world
Replicas: 11 desired | 11 updated | 11 total | 11 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 1 max unavailable, 1 max surge
Pod Template:
Labels: app=hello-world
Containers:
hello-pod:
Image: nigelpoulton/pluralsight-docker-ci:latest
Port: 8080/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
OldReplicaSets: <none>
NewReplicaSet: hello-deploy-2512326018 (11/11 replicas created)
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
--------- -------- ----- ---- ------------- -------- ------
-------
2m 2m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2512326018 to 10
18s 18s 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2512326018 to 11

bash-3.2$ kubectl get services


NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-svc 10.0.0.125 <nodes> 8080:30001/TCP 23h
kubernetes 10.0.0.1 <none> 443/TCP 1d

bash-3.2$ pwd
/Users/user/gitHub/kubernetes-work/Deployments

bash-3.2$ ls
deployment.yml

bash-3.2$ cp deployment.yml deployment-2.yml

bash-3.2$ edit deployment-2.yml


apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-deploy
spec:
replicas: 10
minReadySeconds: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1

template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/pluralsight-docker-ci:edge
ports:
- containerPort: 8080

bash-3.2$ kubectl apply -f deployment-2.yml --record


Warning: kubectl apply should be used on resource created by either kubectl create
--save-config or kubectl apply
deployment "hello-deploy" configured

bash-3.2$ kubectl rollout status deployment hello-deploy


Waiting for rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for rollout to finish: 4 out of 10 new replicas have been updated...
...
Waiting for rollout to finish: 8 out of 10 new replicas have been updated...
Waiting for rollout to finish: 1 old replicas are pending termination...
Waiting for rollout to finish: 1 old replicas are pending termination...
deployment "hello-deploy" successfully rolled out

bash-3.2$ kubectl get deploy hello-deploy


NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-deploy 10 10 10 10 23m

bash-3.2$ kubectl describe deployment hello-deploy


deployments "hello-deploy"
REVISION CHANGE-CAUSE
1 <none>
2 kubectl apply --filename=deployment-2.yml --record=true

NOTE: --record=true used for audit history seen with kubectl rollout history

bash-3.2$ kubectl describe deploy hello-deploy


Name: hello-deploy
Namespace: default
CreationTimestamp: Wed, 13 Sep 2017 11:58:37 -0400
Labels: app=hello-world
Annotations: deployment.kubernetes.io/revision=2

kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"extensions/v1beta1","kind":"Deplo
yment","metadata":{"annotations":{"kubernetes.io/change-cause":"kubectl apply
--filename=deployment-2.y...
kubernetes.io/change-cause=kubectl apply --filename=deployment-2.yml
--record=true
Selector: app=hello-world
Replicas: 10 desired | 10 updated | 10 total | 10 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 10
RollingUpdateStrategy: 1 max unavailable, 1 max surge
Pod Template:
Labels: app=hello-world
Containers:
hello-pod:
Image: nigelpoulton/pluralsight-docker-ci:edge
Port: 8080/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
OldReplicaSets:<none>
NewReplicaSet:hello-deploy-2108007848 (10/10 replicas created)
Events:
FirstSeen LastSeen Count From SubObjectPath Type
Reason Message
----------------- ----- ---- ------------- -------- ------
-------
25m 25m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2512326018 to 10
23m 23m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2512326018 to 11
3m 3m 1 deployment-controller Normal
ScalingReplicaSet Scaled down replica set hello-deploy-2512326018 to 10
3m 3m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2108007848 to 1
3m 3m 1 deployment-controller Normal
ScalingReplicaSet Scaled down replica set hello-deploy-2512326018 to 9
3m 3m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2108007848 to 2
2m 2m 1 deployment-controller Normal
ScalingReplicaSet Scaled down replica set hello-deploy-2512326018 to 7
2m 2m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2108007848 to 4
2m 2m 1 deployment-controller Normal
ScalingReplicaSet Scaled down replica set hello-deploy-2512326018 to 5
2m 2m 1 deployment-controller Normal
ScalingReplicaSet Scaled up replica set hello-deploy-2108007848 to 6
2m 2m 1 deployment-controller Normal
ScalingReplicaSet Scaled down replica set hello-deploy-2512326018 to 3
2m 2m 4 deployment-controller Normal
ScalingReplicaSet (combined from similar events): Scaled down replica set
hello-deploy-2512326018 to 0

bash-3.2$ curl http://192.168.64.3:30001


<html><head><title>Pluralsight Rocks</title><link rel="stylesheet"
href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/></head><body><di
v class="container"><div class="jumbotron"><h1>Yo Kubersighters!!!</h1><p>Click the button
below to head over to the In Tech We Trust podcast...</p><p> <a
href="http://intechwetrustpodcast.com" class="btn
btn-primary">Podcast</a></p><p></p></div></div></body></html>

bash-3.2$ kubectl rollout undo deployment hello-deploy


bash-3.2$ kubectl describe deploy hello-deploy
deployments "hello-deploy"
REVISION CHANGE-CAUSE
1 <none>
2 kubectl apply --filename=deployment-2.yml --record=true

bash-3.2$ kubectl rollout undo deployment hello-deploy --to-revision=1

Waiting for rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for rollout to finish: 2 out of 10 new replicas have been updated...
...
Waiting for rollout to finish: 8 out of 10 new replicas have been updated...
Waiting for rollout to finish: 1 old replicas are pending termination...
Waiting for rollout to finish: 1 old replicas are pending termination...
deployment "hello-deploy" successfully rolled out

bash-3.2$ exit

You might also like