Adding the routing to the ingress controller
Course: Kubernetes Part 2 - chapter 11
Next up, we want to do the following -

- Get rid of all existing deployments in the default namespace
kubectl get deploymentskubectl delete deployment_name- Get rid of all the services in the default namespace (dont delete the default kubernetes service, delete the old
nginxandapacheloadbalancer services)
kubectl get services kubect- Create a
deploymentandservicedefinition for thenginximage/app (this is different from the nginx controller)
apiVersion: apps/v1kind: Deploymentmetadata: name: nginx-deployment namespace: defaultspec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:alpine ports: - containerPort: 80---apiVersion: v1kind: Servicemetadata: name: nginx-service namespace: defaultspec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 type: ClusterIP- Create a deployment and service for the
apacheapp
apiVersion: apps/v1kind: Deploymentmetadata: name: apache-deployment namespace: defaultspec: replicas: 2 selector: matchLabels: app: apache template: metadata: labels: app: apache spec: containers: - name: my-apache-site image: httpd:2.4 ports: - containerPort: 80---apiVersion: v1kind: Servicemetadata: name: apache-service namespace: defaultspec: selector: app: apache ports: - protocol: TCP port: 80 targetPort: 80 type: ClusterIP- Create the ingress resource
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: web-apps-ingress namespace: default annotations: nginx.ingress.kubernetes.io/rewrite-target: /spec: ingressClassName: nginx rules: - host: your-domain.com http: paths: - path: /nginx pathType: Prefix backend: service: name: nginx-service port: number: 80 - path: /apache pathType: Prefix backend: service: name: apache-service port: number: 80Combined manifest
Section titled “Combined manifest”Create a combined manifest with all the api objects
$1b- Apply the manifest
kubectl apply -f complete.yml
- Update your local hosts entry (
/etc/hosts) such that your-domain.com points to the IP of your load balancer
65.20.84.86 your-domain.com- Try going to
[your-domain.com/apache](http://your-domain.com/apache)andyour-domain.com/nginx

