Preface
1. Deployment and Configuration of Ingress1. Get the configuration file #The file has been downloaded locally https://github.com/kubernetes/ingress-nginx/tree/nginx-0.20.0/deploy 2. Prepare the image unzip ingress-nginx-nginx-0.20.0.zip cd ingress-nginx-nginx-0.20.0/deploy/ vim mandatory.yaml #Collection of other files#Edit the mandatory.yaml file and change the defaultbackend image address to the Alibaba Cloud image address (as shown below) image: registry.cn-hangzhou.aliyuncs.com/allinpay/defaultbackend-amd64:v1.5 3. Installation kubectl apply -f mandatory.yaml #Wait a moment and use the following command to query kubectl get namespace kubectl get pods -n ingress-nginx 4. Create backend pod and service (pod-B, service-B) vim deploy-demo.yaml apiVersion: v1 kind: Service metadata: name: myapp namespace: default spec: selector: app: myapp release: canary ports: - name: http targetPort: 80 port: 80 --- apiVersion: apps/v1 kind: Deployment metadata: name: myapp-deploy namespace: default spec: replicas: 3 selector: matchLabels: app: myapp release: canary template: metadata: labels: app: myapp release: canary spec: containers: - name: myapp image: ikubernetes/myapp:v2 ports: - name: http containerPort: 80 #Application configuration kubectl apply -f deploy-demo.yaml #View kubectl get pods 5. Create service-A vim 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 nodePort: 30080 - name: https port: 443 targetPort: 443 protocol: TCP nodePort: 30443 selector: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx #Application configuration kubectl apply -f service-nodeport.yaml #View kubectl get svc -n ingress-nginx Access in an external browser: ip:30080
6. Define ingress rules
vim ingress-myapp.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-myapp namespace: default annotations: kubernetes.io/ingress.class: "nginx" spec: rules: - host: myapp.magedu.com http: paths: - path: backend: serviceName: myapp servicePort: 80
#Application configuration kubectl apply -f ingress-myapp.yaml Configure the host file on the external host Then visit it in the browser again and find that the backend pod can be accessed 2. Use https1. Create a k8s certificate (note that the same namespace is used as the backend pod) kubectl -n default create secret tls ingress-test --key /home/centos/cert/cash432.key --cert /home/centos/cert/cash432.crt 2. Create ingress rules
vim ingress-myapp-cash432.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-myapp namespace: default annotations: kubernetes.io/ingress.class: "nginx" kubernetes.io/secure-backends: "true" kubernetes.io/ssl-passthrough: "true" spec: tls: - hosts: - myapp.cash432.xyz secretName: ingress-test rules: - host: myapp.cash432.xyz http: paths: - path: backend: serviceName: myapp servicePort: 80 #Application configuration kubectl apply -f ingress-myapp-cash432.yaml Browser access This is the end of this article about the steps of deploying ingress-nginx on k8s. For more relevant content about deploying ingress-nginx on k8s, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A solution to a bug in IE6 with jquery-multiselect
>>: How to install Element UI and use vector graphics in vue3.0
Preface The logical judgment statements we use in...
Table of contents About Kubernetes Basic environm...
If you want to exit bash, there are two options: ...
No more nonsense, post code HTML part <div cla...
Table of contents Chain calls A small case Chain ...
In the front-end design draft, you can often see ...
I was recently working on a project about face co...
1. Create a folder to store nginx shell scripts /...
nvm nvm is responsible for managing multiple vers...
Overview For small and medium-sized projects, joi...
Table of contents Learning about WITH queries in ...
Table of contents Preface Several common bit oper...
Strictly speaking, nginx does not have a health c...
If your computer is a Mac, using homebrew to inst...
Preface I wrote a few examples using vue3, and I ...