** Example:1 Deployment ***
vi my-nginx-dep-ser.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx-dep-ser-pod
labels:
app: mynginx-ds
spec:
replicas: 3
selector:
matchLabels:
app: nginx-ds
template:
metadata:
labels:
app: nginx-ds
spec:
containers:
name: my-nginx-dep-ser-container
image: nginx
ports:
containerPort: 80
kubectl create -f my-nginx-dep-ser.yaml
kubectl get pods -l app=nginx-ds
** Example:2 Services**
vi my-nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-nginx-service-pod
spec:
type: ClusterIP
selector:
app: nginx-ds
ports:
protocol: TCP
port: 8080
targetPort: 80
kubectl create -f my-nginx-service.yaml
kubectl get service
kubectl get endpoints my-nginx-service-pod
kubectl get pods [my-nginx-dep-ser-pod-xxxx-xxxx] -o wide
curl [ip]:80