Skip to main content
czerasz.com: notes
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Istio

Headers used for tracing:

  • x-b3-traceid
  • x-b3-spanid
  • x-b3-sampled
  • x-b3-parentspanid

Gateway

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

Virtual Service

Match specific URI:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: api
spec:
  hosts:
  - "*"
  gateways:
  - my-gateway
  # when in different namespace
  # - my-gateway.namespace-name
  http:
  - match:
    - uri:
        exact: /v1/account
    route:
    - destination:
        # the api service
        host: api
        port:
          number: 80

Mutual TLS

Enable Mutual TLS:

apiVersion: authentication.istio.io/v1alpha1
kind: Policy
metadata:
  name: default
  namespace: microservices
spec:
  peers:
  - mtls: {}

Enable mtls

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: frontend
spec:
  # kubernetes Service name
  host: frontend
  trafficPolicy:
    tls:
      mode: ISTIO_MUTUAL
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: backend
spec:
  # kubernetes Service name
  host: backend
  trafficPolicy:
    tls:
      mode: ISTIO_MUTUAL