vim apply -f k8s.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: envirment
name: envirment
namespace: song
spec:
replicas: 1
selector:
matchLabels:
app: envirment
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: envirment
spec:
containers:
- image: 192.168.2.251/qing/en:v1
name: envirment
ports:
- containerPort: 8098
resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
name: envirment
namespace: song
spec:
type: NodePort
selector:
app: envirment
ports:
- nodePort: 8098
port: 8098
protocol: TCP
targetPort: 8098
selector:
app: envirment
sessionAffinity: None
type: NodePort
只需更改其中深色字段,然后运行就可以
kubectl apply -f k8s.yaml