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 官网

下载 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 v1.18.x 部署-Kubeadm方式-9:部署Addon-Nginx Ingress


下一篇:Kubernetes(k8s)1.16.4部署 nginx-ingress 0.30