Deployment

要想让trafic 发现服务,必须把文件写全,否则界面显示红色,

必须包含三个 kind :Deployment  Service   Ingress


[root@prom nginx-ingress]# cat http-test.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: http-test-dm
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: http-test-dm
    spec:
      containers:
      - name: http-test-con
        image: registry.cn-shenzhen.aliyuncs.com/lx0758-per/http-test:latest          #这是一个nginx镜像
    imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: http-test-ser
spec:
  ports: 
  - port: 80
    targetPort: 80
  selector:
    name: http-test-dm
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: grafana
spec:
  rules:
  - host: prom.zhi.io      
    http:
      paths:
      - path: /
        backend:
          serviceName: http-test-ser
          servicePort: 80






暴露端口方式:

[root@lab2 yunwei]# cat ceshi-nainx.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: http-test-dm2
  namespace: development
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: http-test-dm2
    spec:
      containers:
      - name: http-test-con
        image: 10.1.1.71:5000/library/nginx/1.7.9
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: http-nginx-ser
  namespace: development
spec:
  type: NodePort
  ports: 
  - port: 80
    nodePort: 30000
    targetPort: 80
  selector:
    name: http-test-dm2
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  namespace: development
spec:
  rules:
  - host: www.nginx2.com      
    http:
      paths:
      - path: /
        backend:
          serviceName: http-nginx-ser
          servicePort: 80

 

posted @ 2019-03-04 13:20  effortsing  阅读(387)  评论(0编辑  收藏  举报