Kubernettisinterveiw Questions
Kubernettisinterveiw Questions
Kubernettisinterveiw Questions
© Copyright by Interviewbit
Contents
What's Kubernetes?
Kubernetes is a distributed open-source technology which helps us in scheduling and
executing application container within and across clusters. A Kubernetes cluster
consists of two types of resources:
The Master => Coordinates all activities in the cluster, for example, => scheduling
applications, maintaining applications' state, scaling applications, and rolling out
new updates
Nodes => A node is an instance of an OS that serves as a worker machine in a
Kubernetes cluster.
Also, Node will have two components
Kubelet => Agent for managing and communicating with the master
Tool (Docker/containers) => Tools for running container operations
Kubernetes Cluster
POD
The following image describes the work-flow of the Kubernetes from a high level,
wherein the application description is a YAML file also known as configuration or spec
file with the help of which we can deploy applications bundled in the form of pods in
cluster or node
Kubernetes Flow
With the use of limit and request resource usage of a POD can be controlled.
Request: The number of resources being requested for a container. If a container
exceeds its request for resources, it can be throttled back down to its request.
Limit: An upper cap on the resources a single container can use. If it tries to exceed
this predefined limit it can be terminated if K8's decides that another container
needs these resources. If you are sensitive towards pod restarts, it makes sense to
have the sum of all container resource limits equal to or less than the total resource
capacity for your cluster.
Example:
apiVersion: v1
kind: Pod
metadata:
name: demo
spec:
containers:
- name: example1
image:example/example1
resources:
requests:
memory: "_Mi"
cpu: "_m"
limits:
memory: "_Mi"
cpu: "_m"
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: zk-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: zookeeper
Load Balancer
In Kubernetes, as shown in the above figure all the incoming traffic lands to a single
IP address on the load balancer which is a way to expose your service to outside the
internet which routes the incoming traffic to a particular pod (via service) using an
algorithm known as round-robin. Even if any pod goes down load balances are
notified so that the traffic is not routed to that particular unavailable node. Thus load
balancers in Kubernetes are responsible for distributing a set of tasks (incoming
traffic) to the pods
spec:
selector:
app: some-app
ports:
- protocol: UDP
port: 8080
targetPort: 8080
Explanation -
Adding type: LoadBalancer and nodePort as follows:
spec:
selector:
app: some-app
type: LoadBalancer
ports:
- protocol: UDP
port: 8080
targetPort: 8080
nodePort: 32412
metadata:
name: someapp-ingress
spec:
Explanation -
One of the several ways to answer this question.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: someapp-ingress
spec:
rules:
- host: my.host
http:
paths:
- backend:
serviceName: someapp-internal-service
servicePort: 8080
spec:
tls:
- hosts:
- some_app.com
secretName: someapp-secret-tls
apiVersion: v1
kind: ConfigMap
metadata:
name: some-configmap
data:
some_url: silicon.chip
Answer - It's referencing the service "silicon" in the namespace called "chip".
15. What is an Operator?
"Operators are so ware extensions to K8s which make use of custom resources to
manage applications and their components. Operators follow Kubernetes principles,
notably the control loop."
17. What is GKE?
GKE is Google Kubernetes Engine that is used for managing and orchestrating
systems for Docker containers. With the help of Google Public Cloud, we can also
orchestrate the container cluster.
It specifies what to do with an incoming request to the Kubernetes cluster that isn't
mapped to any backend i.e what to do when no rules being defined for the incoming
HTTP request If the default backend service is not defined, it's recommended to
define it so that users still see some kind of message instead of an unclear error.
spec:
containers:
- name: USER_PASSWORD
valueFrom:
secretKeyRef:
name: some-secret
key: password
Explanation -
USER_PASSWORD environment variable will store the value from the password key in
the secret called "some-secret" In other words, you reference a value from a
Kubernetes Secret.
By default, POD should be able to reach the external network but vice-versa we need
to make some changes. Following options are available to connect with POD from
the outer world.
Nodeport (it will expose one port on each node to communicate with it)
Load balancers (L4 layer of TCP/IP protocol)
Ingress (L7 layer of TCP/IP Protocol)
Another method is to use Kube-proxy which can expose a service with only cluster IP
on the local system port.
$ kubectl proxy --port=8080 $
http://localhost:8080/api/v1/proxy/namespaces//services/:/
host: abc.org
http:
paths:
backend:
serviceName: abc-service
servicePort: 8080
Then the service will look like
kind: Service
apiVersion: v1
metadata:
name: abc-service
spec:
ports:
protocol: TCP
port: 8080 # port to which the service listens to
targetPort: 8080
Css Interview Questions Laravel Interview Questions Asp Net Interview Questions