github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/applications/ingress/README.md (about) 1 # Overview 2 3 This image will deploy ingress-nginx as DaemonSet and create an ingress controller class named `k8s.io/ingress-nginx` by 4 default. 5 6 Components included in this image: 7 8 * 1 Job for ingress nginx admission patch 9 * 1 Job for ingress nginx admission create 10 * 1 DaemonSet for ingress nginx controller 11 * 1 Service for ingress nginx controller with LoadBalancer 12 13 ## How to use it 14 15 Create test web service named myapp which exposed 80 port: 16 17 ```yaml 18 apiVersion: v1 19 kind: Service 20 metadata: 21 name: myapp 22 namespace: default 23 spec: 24 selector: 25 app: myapp 26 release: canary 27 ports: 28 - name: http 29 targetPort: 80 30 port: 80 31 --- 32 apiVersion: apps/v1 33 kind: Deployment 34 metadata: 35 name: myapp-deploy 36 namespace: default 37 spec: 38 replicas: 1 39 selector: 40 matchLabels: 41 app: myapp 42 release: canary 43 template: 44 metadata: 45 labels: 46 app: myapp 47 release: canary 48 spec: 49 containers: 50 - name: myapp 51 image: ikubernetes/myapp:v2 52 ports: 53 - name: http 54 containerPort: 80 55 --- 56 ``` 57 58 Create ingress for myapp web service: 59 60 ```yaml 61 apiVersion: networking.k8s.io/v1 62 kind: Ingress 63 metadata: 64 namespace: default 65 name: ingress-myapp 66 spec: 67 rules: 68 - host: myapp.foo.org 69 http: 70 paths: 71 - path: / 72 pathType: Prefix 73 backend: 74 service: 75 name: myapp 76 port: 77 number: 80 78 ingressClassName: nginx 79 80 ``` 81 82 Add node ip and domain name map to hosts file: 83 84 '172.19.0.7' is the node ip of myapp deployment pod. 85 'myapp.foo.org' is the ingress domain name. 86 87 ```shell 88 cat << EOF >>/etc/hosts 89 172.19.0.71 myapp.foo.org 90 EOF 91 ``` 92 93 Access myapp service via domain name: 94 95 ```shell 96 curl myapp.foo.org 97 ``` 98 99 ## How to rebuild it use helm 100 101 Kubefile: 102 103 ```shell 104 FROM registry.cn-qingdao.aliyuncs.com/sealer-apps/helm:v3.6.0 105 # add helm repo and run helm install 106 RUN helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx 107 CMD helm install ingress-nginx --create-namespace --namespace ingress-system ingress-nginx/ingress-nginx 108 ``` 109 110 run below command to build it 111 112 ```shell 113 sealer build -t {Your Image Name} -f Kubefile -m cloud . 114 ``` 115 116 More parameters see [official document here](https://kubernetes.github.io/ingress-nginx/deploy).