Networking Flashcards
Without any service is it possible for two pods to communicate?
Yes, two pods can communicate with each other by using their ip addresses
What command creates a service of type cluster ip?
kubectl create service clusterip a-service-name –tcp (port):(targetPort)
What command creates a deployment and a service together?
kubectl run a-deployment-name –image an-image-name –port (port) –expose
How do you expose a preexisting deployment?
kubectl expose deployment a-deployment-name –port (port) –target-port (targetport)
What is an ingress?
An API object that provides routing rules to manage external users’ access to the services in a Kubernetes cluster
How would you deploy an ingress with rule of type prefix that sets a host to cla.oreilly.com and a target service echoserver:80?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: incoming
namespace: external
annotations:
kubernetes.io/ingress.class: “nginx”
spec:
rules:
- host: cka.oreilly.com
http:
paths:
- backend:
service:
name: echoserver
port:
number: 80
path: /
pathType: Prefix
How would you deploy an ingress with rule of type prefix that sets a host to cla.oreilly.com and a target service echoserver:80?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: incoming
namespace: external
annotations:
kubernetes.io/ingress.class: “nginx”
spec:
rules:
- host: cka.oreilly.com
http:
paths:
- backend:
service:
name: echoserver
port:
number: 80
path: /
pathType: Prefix
Why is it important to annotate an nginx ingress with kubernetes.io/ingress.class: “nginx”?
To ensure the nginx controller picks up the ingress resource