AKS with istio and cert-manager Part 2

2019-11-10

In the previous article here I have explained the setup of Azure AKS with Istio and Cert manager.

Here I shall install a simple liveness service which shall be exposed via the Gateway .

Deploy a sample Kubernetes service shown below. Type of the service here is ClusterIP.

apiVersion: v1
kind: Service
metadata:
  name: liveness-http
  labels:
    app: liveness-http
spec:
  ports:
  - name: http
    port: 80
    targetPort: 8001
  selector:
    app: liveness-http
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: liveness-http
spec:
  template:
    metadata:
      labels:
        app: liveness-http
        version: v1
    spec:
      containers:
      - name: liveness-http
        image: docker.io/istio/health:example
        ports:
        - containerPort: 8001
        livenessProbe:
          httpGet:
            path: /foo
            port: 8001
          initialDelaySeconds: 5
          periodSeconds: 5

The service liveness-http will be exposed outside the cluster with istio configuration.

Since the Gateway is already configured as shown in the previous article. We will configure the VirtualService which will redirect requests inside the cluster. Make sure that the right Gateway is mentioned in the VirtualService for it to redirect to proper kubernetes service.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: liveness-vs
spec:
  hosts:
  - "test.domain.edu"
  gateways:
  - http-gateway.istio-system.svc.cluster.local
  http:
  - match:
    - uri:
        prefix: /foo
    route:
    - destination:
        host: liveness-http
        port:
          number: 80

As simple as this, the service is now available at https://test.domain.edu/foo

I assume here that istio configuration such as sidecar injection and slight advanced topic such as mTLS is already taken by you! Please feel free to comment and let me know if those details are needed(of course which is totally another topic) I can write it down as well.