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
To replace a string, we need to use the following...
Using the image service deployed by docker stack,...
First, your container must be running You can vie...
Preface 1. Debounce: After a high-frequency event...
This article shares the Vant Uploader component f...
Plot Review In the previous article, we analyzed ...
1. IE browser mode Hack logo 1. CSS hack logo Copy...
1. Install mutt sudo apt-get install mutt 2. Inst...
Table of contents Linux netstat command 1. Detail...
When using MySQL 5.7, you will find that garbled ...
Last weekend, a brother project was preparing to ...
This article example shares the specific code of ...
Preface One day, I was suddenly asked about MySQL...
The Meta tag is an auxiliary tag in the head area...
question: I have a form in Vue for uploading blog...