service objects Flashcards
CKA cert in 26 days
a ______ is used to set up networking in our kube cluster. Making it easily accessible externally
websites. gui. people outside need to access webserver.
publicly.
SERVICE OBJECT
4 types of services
CLUSTERIP
NODEPORT
LOADBALANCER
INGRESS
which ONE of the 4 services SHOULD ONLY BE USED FOR DEV ENVIRONMENTS?
is NOT GOOD FOR PRODUCTION ENVIORNMENTS
NODEPORT
apiVersion: v1 kind: Service metadata: name: svc-nodeport-httpd spec: type: NodePort ports: - port: 3050
WHAT IS -port: 3050
Used by other pods so they can access the assets in container. from another pod, you can connect to this specific pod on PORT 3050
apiVersion: v1 kind: Service metadata: name: svc-nodeport-httpd spec: type: NodePort ports: - port: 3050 targetPort: 80
WHAT IS -targetPort: 80
port number the pods primary container is listening on. Needs to mirror containerport setting as defined in the object config file (yaml file that created the pod)
apiVersion: v1 kind: Service metadata: name: svc-nodeport-httpd spec: type: NodePort ports: - port: 3050 targetPort: 80 nodePort: 31000
WHAT IS nodePort 30000-32767
nodePort will always range between 30000-32767
- kube-proxy component listens on this port for the worker node.
- to access container from webbrowser youd need to use this port.
- ^^^ the drawback to using nodeport service type
apiVersion: v1 kind: Service metadata: name: svc-nodeport-httpd spec: type: NodePort ports: - port: 3050 targetPort: 80 nodePort: 31000 selector: app: apache_webserver
it will forward traffic to object that has
‘app: apache_webserver’ as a metadata in yml file.
COMMAND to CREATE a SERVICE OBJECT with :
svc-nodeport.yml
kubectl apply -f configs/svc-nordeport.yml
VIEW ALL OBJECTS COMMAND
kubectl get all -o wide
if the minikube ip is 192.168.99.107 and the nodeport is 31000.
how would you run the CURL COMMAND on to TEST THE ENDPOINT
curl http://192.168.99.100:31000
another way to run curl command to TEST THE ENDPOINT
is to run:
$ minikube service svc-nodeport-httpd –url
to show the IP and then…
curl $(minikube service svc-nodeport-httpd –url)
DELETE ALL OBJECTS
kubectl delete all -all
DELETE WITH GRACEPERIOD
kubectl delete -f ./configs –grace-period=2