Apply the changes like:
kubectl create -f pod.yaml
or
kubectl delete -f pod.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nchase
name: nchase
spec:
replicas: 1
selector:
matchLabels:
app: nchase
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nchase
spec:
containers:
- image: nickchase/rss-php-nginx:v1
name: rss-php-nginx
resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
spec:
ports:
- name: 80-80
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancer
status:
loadBalancer: {}
kubectl run mypod --image=nginx:latest \
--labels type=web \
--dry-run=client -o yaml > mypod.yaml
kubectl expose pod mypod \
--port=80 \
--name mypod-service \
--type=NodePort \
--dry-run=client -o yaml > mypod-service.yaml
Create a service type nodeport with port 30001 with service to pod TCP port mapping on port 80.
kubectl create service nodeport mypod \
--tcp=80:80 \
--node-port=30001 \
--dry-run=client -o yaml > mypod-service.yaml
Create a deployment named mydeployment with image Nginx
kubectl create deployment mydeployment \
--image=nginx:latest \
--dry-run=client -o yaml > mydeployment.yaml
Create a NodePort service YAML for deployment mydeployment with service port 8080
kubectl expose deployment mydeployment \
--type=NodePort \
--port=8080 \
--name=mydeployment-service \
--dry-run=client -o yaml > mydeployment-service.yaml