kubectl get nodes
#需要三个配置文件:
vim nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
name: nginx-pod
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
vim nginx-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-rc
spec:
replicas: 2
selector:
name: nginx-pod
template:
metadata:
labels:
name: nginx-pod
spec:
containers:
- name: nginx-pod
image: nginx
ports:
- containerPort: 80
vim nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-service-nodeport
spec:
ports:
- port: 8000
targetPort: 80
protocol: TCP
type: NodePort
selector:
name: nginx
kubectl create -f nginx-pod.yaml
kubectl describe pod nginx
create -f nginx-rc.yaml
create -f nginx-service.yaml
kubectl get pods -o wide
kubectl get svc
kubectl get rc
访问nginx:
http://192.168.91.26:30011
http://192.168.91.27:30011
签名:这个人很懒,什么也没有留下!