Class 5 - Expose App, Scale App and Update App Flashcards

1
Q

What are Kubernetes Nodes?

A
  • A node is main worker machine
  • AKA minions
  • Could run on physical machine or VM
  • Provides all necessary services to run pods
  • Are managed by master
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which are key services running on Node?

A
  • Container Engine (docker, rkt)
  • Kubelet
  • Kube-proxy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when we do kubeadm join command to create a node?

A

Kubeadm collects metadata about the machine and stores that object in etcd.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens when we delete the node?

A

On deleting the node, the object that is stored in etcd about that machine is removed. Actual VM is not removed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Categories of Kubernetes node status? (HINT there are 4 categories)

A

Kubernetes node status shows valuable information for planning and managing operations.

  1. Address (internal or external IP) - Static
  2. Condition (current state of node) - Dynamic
  3. Capacity (current capacity of node) - Dynamic
  4. Info - Static
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which command can be used to view node status?

A

kubectl describe node

will show details about all 4 categories of status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the condition category of node status?

A

Kubernetes keeps on getting current health check of node. That includes memory pressure, disk pressure, PID pressure etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Ready condition of node?

A

Ready condition is true when all the other conditions are false. If any condition becomes true, the node status changes to either NotReady, MemoryOutOfBounds, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What information does Kubernetes node status - Capacity category provide?

A

Describes the resources available on the node. Using this information, you can decide on the number of pods that can be scheduled.
CPU, Memory, Storage are some capacity information available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Capacity vs Allocatable?

A

Capacity is the actual resources that are available on the node and allocatable shows how many are free for allocation at any point in time, after subtracting resources taken by OS, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What information does Kubernetes node status - System info provide?

A

It shows Kernel info, OS details, Kubernetes details (version, kubelet version, kube proxy version etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In Kubernetes cluster is node created by Kubernetes itself?

A

No, a node is not created by Kubernetes. They are created outside of it like on a bare-metal, VM or public cloud.
On creating node in Kubernetes
- It creates an object to the present node
- It validates the object to quality it for running a Pod
- If it doesn’t qualify then it will keep the node in Invalid state unless it is deleted or fixed by admin to qualify.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which are the three ways to interact with the nodes?

A
  • KubeController - kubectl
  • Kubelet
  • Node Controller
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which command can be used to edit a node?

A

kubectl edit node

will allow changing node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Who controls IP addresses of pods on a node?

A

NodeController controls IP addresses of pods running. Each node gets its block of IP address which it uses to allocate IP address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which are the responsibility of Node Controller?

A

It is part of Kubernetes master

  • Assign CIDR blocks to nodes
  • Maintain list of nodes
  • Monitor health of nodes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is Kubernetes Service?

A

Kubernetes service acts as a load balancer. A service can cater to one or more pods. Multiple pods point to single service resource.

Services are nothing but another type of resource which allows pods to be exposed to other pods in cluster or expose the pods to the external world.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are Kubernetes services equivalent to?

A

They are equivalent to IP Table rules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How to decide which pod should be assigned to which service? What are the conventions?

A

Ideally one service per applciation type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which IP address is assigned to service resource?

A

Service resource are assigned a totally different IP than pod CIDR service.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Is service resource static or dynamic resource and can it fail?

A

Service resource is static resource and it cannot fail. It has fixed IP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What type of Service resource will you create when you want a application to be available within cluster?

A

ClusterIP service resource can be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Do we care which IP address the service is provided?

A

Not really, because pod can connect to the service using DNS name which is service name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Is pod to pod direct communication possible using pod name?

A

No a pod to pod communication is not possible directly using pod name, only through service can this be done.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Suppose we want expose a pod to the external world, which are the ways to do that?

A

There are two types of service resource that allow us to do that

1) NodePort - which is same as docker port mapping, where in internal container port will be mapped with host machine port.
2) LoadBalancer - it is same as NodePort with the difference is that it assigns external IP address. This is only available for cloud deployments and not available for on-premise deployments. Only on Managed Kubernetes Services.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Example command to expose a nginx pod using ClusterIP service type?

A

kubectl expose pod –port= –type=ClusterIP
When we don’t provide external port then Kubernetes itself assigns.

The cluster IP will be static IP and will be different than Pod network CIDR.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which command can be used to display Kubernetes service?

A

kubectl get svc
or
kubectl get services

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Can service by service name be accessible from outside the pod?

A

No, the service DNS mapping in internal to pod cluster and will not be accessible outside the cluster.

29
Q

Command to view details of service?

A

kubectl describe svc

30
Q

How to find which endpoints are connected to a particular service?

A

kubectl describe svc

will have Endpoints which will have IP:port of multiple pods that are pointing to same service.

31
Q

Command to delete a service?

A

kubectl delete svc

32
Q

Command to create a NodePort service?

A

kubectl expose pod –port=80 –type=NodePort

On doing this kubernetes will automatically assign an external port in configurable range.
So after doing that the service can be reached by using
kmaster: or knode1: etc.

33
Q

Where are the external ports occupied when creating NodePort resource?

A

The external port is occupied on whole cluster. So on all nodes firing netstat will how port occupied by kube-proxy service.

34
Q

Command to quickly run nginx image using Kubernetes?

A

kubectl run nginx –image=nginx

35
Q

Where are labels defined in Kubernetes?

A

It is inside the metadata section of kubernetes yaml file.

36
Q

Where are labels defined in Kubernetes?

A

It is inside the metadata section of kubernetes yaml file.

37
Q

What can be kept in label?

A

Label is any key value pair that makes sense to devops team, etc.

38
Q

What happens if you have two pods (nginx and mysql) with same labels and when you expose nginx pod with ClusteIP type service called nginx?

A

On doing
kubectl describe svc nginx
You will find that endpoints have two entries, one for nginx and other for mysql even though we didn’t expose mysql pod.

39
Q

Why does creating service resource on a particular pod with same label as some other pod, expose both the pods?

A

Because in Kubernetes whenever you create a resource, they don’t work on top of pods. They don’t map to the pod, they map to the LABEL of the pod.

40
Q

What does resources in Kubernetes map to? Pods or Labels?

A

Resources in Kubernetes map to labels of pods and not pods.

41
Q

What are labels?

A
  • Key value pairs
  • Attached to pods, replication controllers
  • used to identify and organize objects
  • Can be created at time of creation of pod
  • Can be added or modified after pod creation as well
42
Q

What happens if there is no label and we try to create a service resource?

A

If there is no label associated with a particular pod, then the service will FAIL and say that there is no label.

43
Q

What are labels and resources assigned to?

A

Labels -> Pods

Selectors -> Resources (like service)

44
Q

What are selectors?

A

Labels don’t provide uniqueness

  • With selectors, application/user can pick group of objects by it’s label
  • Core grouping mechanism in Kubernetes
45
Q

How many types of selectors are supported in Kuberntes?

A

2 types

  • Equality based selector
  • Set based selector
46
Q

What can be given in equality based selectors?

A

Useful for filtering by key-value maching
Only == and != operators can be used.
You cannot give expression such as
app=v1 & app=v2 and such

47
Q

Can we give expression like && and || in Equality based selector?

A

No we can only give simple == or != check in equality based selector.

48
Q

What capability we have in set based selector?

A

Allows filtering of keys based on set of values

  • Three operators are supported
  • in
  • not in
  • exists

this allows fine grained control over selection.

e.g. team in (HR, training)
This will match for team value equal to HR or training

exists(Club)
Club: matches all resources with label ‘club’. No values are matched.

49
Q

Difference between Replication controller and Replica Set?

A

Replication controller only supports equality based selectors
Replica set supports set based selector so it is much more powerful.

50
Q

What is replication controller?

A

It is a super set of pod and its job is to achieve the desired state by making sure desired state number of pods are always running

51
Q

What are jobs of replication controller?

A
  • Achieve desired state
  • Create new pod if existing one crashes or is killed
  • Update or delete multiple pods with single command
  • Helps to create, scale and maintain multiple pods as part of desired state.
52
Q

Is replication controller a dynamic or static thing?

A

Replication controller is just a resource in which desired state is defined.

53
Q

Command to delete all pods?

A

kubectl delete pods –all

54
Q

Sample yaml file to create Replication Controller

A
apiVersion: v1
kind: ReplicationController
metadata:
  name: myrc
  labels:
    app: replicationcontroller
spec:
  replicas: 5
  selector:
    app: myapp
  template:
    metadata:
      name: nginx
      labels:
        app: myapp
    spec:
      containers:
        - name: nginx
          image: nginx

Replication controller will govern all pods that have selector as app = myapp.

55
Q

What happens if you run replication controller which will govern app = myapp with replication of 5 and there are already 2 pods running with the selector?

A

If there are already two pods running with label app= myapp, it will only create 3 more pods. If replication controller cannot find any with defined selector then it will create 5.

56
Q

Command to view replication controller?

A

kubectl get replicationcontroller
or
kubectl get rc

57
Q

What information does kubectl get replicationcontroller show?

A

NAME, DESIRED, CURRENT, READY, AGE

myrc, 5, 5, 5, 14s

58
Q

Command to view detail information about a replication controller?

A

kubectl describe rc

59
Q

Can we create a service to expose ReplicationController?

A

Yes we can do that as far as the replication controller has a label associated with it.

60
Q

Command to expose a replication controller with NodePort type?

A

kubectl expose rc –port 80 –type=NodePort
This will expose the rc and firing describe on service will show n endpoints being exposed where n is the replication count.

61
Q

Replica Set vs Replication Controller

A

Exact same functionalities.
Replica Set supports set based selectors whereas Replication controller supports equality based selectors.
Replica set makes it easy to do blue-green deployments, canary based deployments.

62
Q

Does Replica Set support updates? Does Replication Controller support updates? Does Deployment controller support updates?

A

Replication Controller allows to update image names or image versions.
Replica Sets don’t allow updates.

“Updates are not feature of Replica Set”

Yes deployment controller does support updates.

63
Q

Sample yaml file for Replica Set

A
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: mysqlrs
  labels:
    app: mysql
spec:
  replicas: 3
  selector:
    matchExpressions:
      - {key: app, operator: In, values: [mysql_1, mysql_2]}
    template:
      but with mysql_2 label
64
Q

Difference between matchExpressions vs matchLabels in ReplicaSet?

A

matchExpressions - set based selector

matchLabels - equality based selector

65
Q

Command to get list of replica sets

A

kubectl get replicaset
or
kubectl get rs

66
Q

Command to view detail of replica sets

A

kubectl describe replicaset

67
Q

Key uses of Deployment controller

A
  • Rollout of new replicaset
  • Rollback to earlier version
  • Scale up to handle more load
  • Define new state of the pods (update labels etc)
68
Q

Relation between ReplicationController, ReplicaSet and Deployment Controller

A

DeploymentController is superset of ReplicaSet, which is super set of ReplicationController

69
Q

Important properties of Deployment Controller

A
  • revisionHistoryLimit : 5
    How many history (previous) instances of replicaset will be kept available for us to do rollback

rollingUpdate:
maxUnavailable: 1
maxSurge: 2

maxUnavailable means lets say system can handle full load using only n - 1 instances. So during the update one instance and only one instance can go down. Total no of pods that can go down during rolling update.

maxSurge means how many additional pods can come up on top of your replicas. So when we update one instance at a time (due to max unavailable as 1), deployment controller will spin up new ReplicaSet with 3 = (replicas: 3 - 1 (is down)) + maxSurge)
Once update finishes state goes back to 3 replicas as older replica set pods will be deleted.