LFS258-LAB-Services

部署service

1.创建 deployment

student@ubuntu:~/job$cat nginx-one.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-one
  labels:
    system: secondary
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        imagePullPolicy: Always
        name: nginx
        ports:
        - containerPort: 80
          protocol: TCP

student@ubuntu:~/job$kubectl create -f nginx-one.yaml
  1. 创建service
student@ubuntu:~/job$kubectl expose deployment nginx-one 
service/nginx-one exposed

student@ubuntu:~/job$kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1                443/TCP   5d17h
nginx-one    ClusterIP   10.106.204.175           80/TCP    4s

student@ubuntu:~/job$curl 10.106.204.175



Welcome to nginx!