K8s contd
Exercise- Replicaset
-
create a replicaset with pod spec running alpine container without any args
- I want to create a replicaset with nginx and want to access them from browser
Service
- Refer Here for official docs
Trail 1:
- Create a service to forward the request to 80 port of nginx pods with label
app:nginx - Refer Here for the manifest
- Access the svc as discussed in the class
Trail 2:
- Create a replica set with 3 httpd pods
- create a service with some matching labels
- Refer Here for the changes and apply manifests
- When we create a service, service creates endpoint which all the ip-addresses of matching pods
- If we want to access the svc from outside or use node-network we have two options
- temporary:
kubectl port-forward - continued access: for this we need to understand service types in k8s
- temporary:
Service Types
- k8s service is of 4 types Refer Here
- cluster ip:
- this gives private access with in k8s cluster
- nodeport:
- k8s service can be exposed on a specific port (30000-32767) on all nodes of k8s cluster
- load balancer: This is used generally by managed k8s clusters (EKS, AKS), This creates a cloud load balancer
- externalName:
- cluster ip:
Trail 2 Continued:
- Modify the service to expose the apache service on port 30000
- Refer Here for the changes
Trail3
- Create a replica set with spring petclinic image
shaikkhajaibrahim/spcjan2024:1.0- This runs on 8080 port
- Now create 3 replicas of this
- label suggestions:
- app: spc
- env: dev
- version: v3.4.0
- Create a service of type cluster ip
- expose this to the outside world on port 31000 using node port
- Refer Here for the manifests
Exercises
- figure out the purpose of /etc/resolve.conf
