This guide walks through the steps required to connect kubectl to a BTP Kyma environment using an AWS EC2 instance as the intermediary host.
<KEY_PAIR_NAME>.pem).oneconnectkyma.zip deployment file.Placeholder values are shown in square brackets < >. Replace them with your actual values before executing any command.
| Placeholder | Description |
|---|---|
<KEY_PAIR_NAME>.pem |
Name of the EC2 .pem key file |
<EC2_USER> |
SSH user for the EC2 (e.g., ec2-user, ubuntu) |
<EC2_PUBLIC_IP> |
Public IP address of the EC2 instance |
Open PowerShell on Windows and set the correct permissions on the .pem file so that SSH accepts it:
| icacls ".\<KEY_PAIR_NAME>.pem" /inheritance:r icacls ".\<KEY_PAIR_NAME>.pem" /grant:r "$($env:USERNAME):(R)" |
Connect to the EC2 instance including the port tunnels required for Kyma OIDC authentication:
| ssh -i ".\<KEY_PAIR_NAME>.pem" -L 8000:localhost:8000 -L 18000:localhost:18000 <EC2_USER>@<EC2_PUBLIC_IP> |

-L 8000:localhost:8000 and -L 18000:localhost:18000 parameters create an SSH tunnel that allows Kyma's OIDC authentication (which opens a browser on port 8000) to work from the local machine.Run the following commands inside the EC2 instance:
| curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x kubectl sudo mv kubectl /usr/local/bin/ kubectl version --client |

Run the following commands inside the EC2 instance:
| curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash helm version |
Kyma uses OIDC authentication, so the kubelogin plugin is required for kubectl to authenticate:
| curl -LO https://github.com/int128/kubelogin/releases/latest/download/kubelogin_linux_amd64.zip unzip kubelogin_linux_amd64.zip sudo mv kubelogin /usr/local/bin/kubectl-oidc_login kubectl oidc-login --version |
Download the project ZIP file and extract it:
| curl -O https://oneconnectdeploymentaks.s3.us-east-2.amazonaws.com/oneconnectkyma/oneconnectkyma.zip unzip oneconnectkyma.zip |

unzip is not installed, run: sudo yum install unzip -yDownload the kubeconfig file from the Kyma Environment Broker and set it as an environment variable
Placeholder values are shown in square brackets < >. Replace them with your actual values before executing any command.
| Placeholder | Description |
|---|---|
<ENVIRONMENT_INSTANCE_ID> |
Kyma instance ID (from SAP BTP Cockpit) |
| curl -L "https://kyma-env-broker.cp.kyma.cloud.sap/kubeconfig/<ENVIRONMENT_INSTANCE_ID>" -o kubeconfig.yaml export KUBECONFIG=~/kubeconfig.yaml |

<ENVIRONMENT_INSTANCE_ID> can be found in the SAP BTP Cockpit under the Kyma Environment section of your subaccount. If unzip is not installed, run: sudo yum install unzip -yRun the following command to verify the connection:
| kubectl get namespaces |
When running this command, a message will appear in the console asking you to open http://localhost:8000 for authentication.
Open that URL in your local machine browser (Windows), sign in with your SAP BTP credentials, and return to the terminal.
The command should list the Kyma cluster namespaces, confirming a successful connection.