k8s-部署應用

Deployment

# app-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-web
spec:
  selector:
      matchLabels:
        app: app-web-v1
  replicas: 3
  template:
    metadata:
      labels:
        app: app-web-v1
    spec:
      containers:
      - name: myapp
        image: zzzwangjun/apps:v1
        ports:
        - containerPort: 80

SVC

# app-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: app-svc
spec:
  selector:
    app: app-web-v1
  ports:
  - protocol: TCP
    port: 8200
    targetPort: 80

Ingress Ningx

  • Ingress主要實現集羣內全部服務的入口,經過一系列規則集合來容許外部的訪問。
  • Ingress能夠配置爲提供服務外部訪問的URL,負載均衡,SSL,提供基於名稱的虛擬主機等。而ingress的具體實現是由ingress Controller實現。

Ingress Ningx 官網html

下載 mandatory.yaml

kubectl create -f mandatory.yaml

經過NodePort方式暴露

# service-nodeport.yaml
apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  type: NodePort
  ports:
    - name: http
      port: 80
      targetPort: 80
      protocol: TCP
    - name: https
      port: 443
      targetPort: 443
      protocol: TCP
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx

K8s-安裝
K8s-Pod
K8s-應用部署
K8s-Helmnode

相關文章
相關標籤/搜索