Service Mesh

Overview

Kyma Service Mesh is the component responsible for service-to-service communication, proxying, service discovery, traceability, and security. To deliver this functionality, Kyma Service Mesh uses Istio open platform.

The main principle of Kyma Service Mesh is to inject Pods of every service with the Envoy sidecar proxy. Envoy intercepts the communication between the services and regulates it by applying and enforcing the rules you create. Kyma Dex, which is also a part of the Service Mesh, allows you to integrate any OpenID Connect-compliant identity provider or a SAML2-based enterprise authentication server with your solution.

By default, Istio in Kyma has mutual TLS (mTLS) enabled and injects a sidecar container to every Pod. You can manage mTLS traffic in services or at a Namespace level by creating Destination Rules and Peer Authentications. If you disable sidecar injection in a service or in a Namespace, you must manage their traffic configuration by creating appropriate Destination Rules and Peer Authentications.

NOTE: The Istio Control Plane doesn't have mTLS enabled.

NOTE: For security and performance we use the distroless version of Istio images. Those images are not Debian-based and are slimmed down to reduce any potential attack surface and increase startup time.

You can install Service Mesh as part of Kyma predefined profiles. For production purposes, use the production profile which has increased resource quotas for all Istio components. It also has Horizontal Pod Autoscaler (HPA) enabled for all Istio components.

Details

Istio setup in Kyma

Istio in Kyma is installed with the help of the istioctl tool. The tool is driven by a configuration file containing an instance of IstioOperator custom resource. There are two configuration files — one for local installation on Minikube and one for cluster installations. The configurations are customized for Kyma and are stored in the resources/istio/files directory.

Istio components

This list shows the available Istio components and the components enabled in Kyma:

ComponentEnabled
Istiod
Ingress Gateway✅️
Egress Gateway⛔️
CNI⛔️
Grafana⛔️
Prometheus⛔️
Tracing⛔️
Kiali⛔️

Kyma-specific configuration

These configuration changes are applied to customize Istio for use with Kyma:

  • Automatic sidecar injection is enabled by default, excluding the istio-system and kube-system Namespaces.
  • New resource requests for Istio sidecars are introduced: CPU: 20m, memory: 32Mi.
  • New resource limits for Istio sidecars are introduced: CPU: 200m, memory: 128Mi.
  • Mutual TLS (mTLS) is enabled cluster-wide in a STRICT mode.
  • Global tracing is set to use the Zipkin installation provided by Kyma.
  • Ingress Gateway is expanded to handle ports 80 and 443 for local Kyma deployments.
  • DestinationRules are created by default, which disables mTLS for the kubernetes.default.svc.cluster.local service. In local (Minikube) installation mTLS is also disabled for istio-ingressgateway.istio-system.svc.cluster.local service.
  • The istio-sidecar-injector Mutating Webhook Configuration is patched to exclude Gardener resources in the kube-system namespace and the timeout is set to 10 seconds.
  • All Istio components have decreased resource requests and limits.
  • The use of HTTP 1.0 is enabled in the outbound HTTP listeners by PILOT_HTTP10 flag set in Istiod component environment variables.

Sidecar Proxy Injection

By default, istiod watches all Pod creation operations on all Namespaces and injects the newly created Pods with a sidecar proxy.

You can disable sidecar proxy injection for either an entire Namespace or a single Deployment.

  • To disable sidecar proxy injection for a Namespace, set the istio-injection label value to disabled for the Namespace in which you want to disable the sidecar proxy injection. Use this command: kubectl label namespace {YOUR_NAMESPACE} istio-injection=disabled
  • To disable sidecar proxy injection for a Deployment, add this annotation to the Deployment configuration file: sidecar.istio.io/inject: "false"

Read the Istio documentation to learn more about sidecar proxy injection.

Configuration

Istio custom configuration

The Istio installation in Kyma uses the IstioOperator API. Kyma provides the default IstioOperator configurations for local (Minikube) and cluster installations, but you can add a custom IstioOperator definition that overrides the default settings.

The definition you provide may be a partial one with not all the options specified. In that case, it will be merged with the defaults.

To provide a custom IstioOperator configuration, define a Kyma Installation override with the kyma_istio_operator key. The value for this override must be a single string containing a valid definition of the IstioOperator custom resource, in the YAML format.

TIP: To learn more about how to use overrides in Kyma, see the following documents:

See the following example that customizes settings for the policy and pilot components of Istio:

Click to copy
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: istio-operator-overrides
namespace: kyma-installer
labels:
installer: overrides
component: istio
kyma-project.io/installation: ""
data:
kyma_istio_operator: |-
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
namespace: istio-system
name: example-istiooperator
spec:
components:
policy:
k8s:
hpaSpec:
minReplicas: 2
pilot:
k8s:
resources:
requests:
memory: 3072Mi
env:
- name: PILOT_TRACE_SAMPLING
value: "20"
```

While installing with Kyma CLI, don't forget to provide this file's path via -o flag.

Refer to the IstioOperator API documentation for details about available options.

Troubleshooting

Overview

The troubleshooting section aims to identify the most common recurring problems with the Kyma Service Mesh, as well as the most suitable solutions to these problems.

If you can't find a solution to your problem, don't hesitate to create a GitHub issue or reach out to the #service-mesh Slack channel to get direct support from the community.

Can't access Console UI or other endpoints

The 503 status code received when you try to access the Console UI or any other endpoint in Kyma can be caused by a configuration error in the Istio Ingress Gateway. As a result, the endpoint you call is not exposed. To fix this problem, restart the Pods of the Gateway.

  1. List all available endpoints:

    Click to copy
    kubectl get virtualservice --all-namespaces
  2. Restart the Pods of the Istio Ingress Gateway to force them to recreate their configuration:

    Click to copy
    kubectl delete pod -l app=istio-ingressgateway -n istio-system

If this solution doesn't work, you need to change the image of the Istio Ingress Gateway to allow further investigation. Kyma uses distroless Istio images which are more secure, but you cannot execute commands inside them. Follow this steps:

  1. Edit the Istio Ingress Gateway Deployment:

    Click to copy
    kubectl edit deployment -n istio-system istio-ingressgateway
  2. Find the istio-proxy container and delete the -distroless suffix.

  3. Check all ports used by the Istio Ingress Gateway:

    Click to copy
    kubectl exec -ti -n istio-system $(kubectl get pod -l app=istio-ingressgateway -n istio-system -o name) -c istio-proxy -- netstat -lptnu
  4. If ports 80 and 443 are not used, check the logs of the Istio Ingress Gateway container for errors related to certificates. Run:

    Click to copy
    kubectl logs -n istio-system -l app=istio-ingressgateway -c ingress-sds
  5. In case of certificate-related issues, make sure kyma-gateway-certs and app-connector-certs Secrets are available in the istio-system Namespace and that they contain proper data. Run:

    Click to copy
    kubectl get secrets -n istio-system kyma-gateway-certs -oyaml
    kubectl get secrets -n istio-system app-connector-certs -oyaml
  6. To regenerate a corrupted certificate, follow this tutorial. If you are running Kyma provisioned through Gardener, follow this tutorial instead.

    NOTE: Remember to switch back to the distroless image after you resolved the issue.

Connection refused errors

Mutual TLS (mTLS) is enabled in the Service Mesh by default. As a result, every element of the Service Mesh must have an Istio sidecar with a valid TLS certificate to allow communication. Attempts to establish connection between a service without a sidecar and a service with a sidecar result in a Connection reset by peer or a GOAWAY response.

  • To enable sidecar injection for Pods of existing Services, restart them after upgrading Kyma.
  • To whitelist a Service without a sidecar and disable mTLS traffic for it, create a DestinationRule.
  • To allow connections between Services without a sidecar and a Service with a sidecar, create a Peer Authentication in the PERMISSIVE mode.

    NOTE: In Istio 1.5, Peer Authentication replaces the deprecated Authentication Policy.

Issues with Istio sidecar injection

Kyma has sidecar injection enabled by default - a sidecar is injected to every Pod in a cluster without the need to add any labels. For more information, read this document. If a Pod doesn't have a sidecar and you did not disable sidecar injection on purpose, follow these steps to troubleshoot:

  1. Check if sidecar injection is disabled in the Namespace of the Pod. Run this command to check the istio-injection label:

    Click to copy
    kubectl get namespaces {NAMESPACE} -o jsonpath='{ .metadata.labels.istio-injection }'

    If the command returns disabled the sidecar injection is disabled in this Namespace. To add a sidecar to the Pod, move the Pod's deployment to a Namespace that has sidecar injection enabled, or remove the label from the Namespace and restart the Pod.

    WARNING: Removing the istio-injection=disabled label from Namespace results in injecting sidecars to all Pods inside of the Namespace.

  2. Check if sidecar injection is disabled in the Pod's Deployment:

    Click to copy
    kubectl get deployments {DEPLOYMENT_NAME} -n {NAMESPACE} -o jsonpath='{ .spec.template.metadata.annotations }'

    Sidecar injection is disabled if the output contains the sidecar.istio.io/inject:false line. Delete the label and restart the Pod to enable sidecar injection for the Deployment.

For more information, read this document or follow the Istio documentation.

Incompatible Istio sidecar version after Kyma upgrade

Kyma has sidecar injection enabled by default - a sidecar is injected to every Pod in a cluster without the need to add any labels. For more information, read this document.

The sidecar version in Pods must match the installed Istio version. Otherwise, mesh connectivity may be broken. This issue may appear during Kyma upgrade. When Kyma is upgraded to a new version along with a new Istio version, existing sidecars injected into Pods remain in an original version. Kyma contains the istio-proxy-reset job that performs a rollout for most common workload types, such as Deployments, DaemonSets, etc. The job ensures all Kyma components are properly updated. However, some user-defined workloads can't be rolled out automatically. This applies, for example, to a standalone Pod without any backing management mechanism, such as a ReplicaSet or a Job. Such user-defined workloads, that are not part of Kyma, must be manually restarted to work correctly with the updated Istio version.

To check if any Pods or workloads require a manual restart, follow these steps:

  1. Check the installed Istio version using one of these methods:

    • From the istiod deployment in a running cluster:

      Click to copy
      export KYMA_ISTIO_VERSION=$(kubectl get deployment istiod -n istio-system -o json | jq '.spec.template.spec.containers | .[].image' | sed 's/[^:"]*[:]//' | sed 's/["]//g')
    • From Kyma sources - run this command from within the directory that contains Kyma sources:

      Click to copy
      export KYMA_ISTIO_VERSION=$(cat resources/istio/Chart.yaml | grep version | sed 's/[^:]*[:]//' | sed 's/ //g')
  2. Get the list of objects which require rollout using one of these methods:

    • Find all Pods with outdated sidecars. The returned list follows the name/namespace format. The empty output means that there is no Pod that requires migration. To find all outdated Pods, run:
      Click to copy
      COMMON_ISTIO_PROXY_IMAGE_PREFIX="eu.gcr.io/kyma-project/external/istio/proxyv2"
      kubectl get pods -A -o json | jq -rc '.items | .[] | select(.spec.containers[].image | startswith("'"${COMMON_ISTIO_PROXY_IMAGE_PREFIX}"'") and (endswith("'"${KYMA_ISTIO_VERSION}"'") | not)) | "\(.metadata.name)/\(.metadata.namespace)"'
Click to copy
* Run the `istio-proxy-reset` script in the dry-run mode. The output contains information about objects, such as Pods, Deployments, etc., that require rollout. To run the script, run this command from within the directory with checked-out Kyma sources:
```bash
EXPECTED_ISTIO_PROXY_IMAGE="${KYMA_ISTIO_VERSION}"
COMMON_ISTIO_PROXY_IMAGE_PREFIX="eu.gcr.io/kyma-project/external/istio/proxyv2"
DRY_RUN="true"
./resources/istio/files/istio-proxy-reset.sh
```

After you find a set of objects that require the manual update, restart their related workloads so that new Istio sidecars are injected into the Pods.