In some use cases it's useful to run k9s inside the cluster in a pod.
It would be great to be able to directly use the Service Account's credentials. Currently k9s requires a $KUBECONFIG file. In other words, currently k9s cannot use credentials in /var/run/secrets/kubernetes.io/serviceaccount/ without first converting them to $KUBECONFIG.
Workaround is to create $KUBECONFIG before starting k9s, but that's boilerplate and requires a wrapper script for k9s (not nice).
The rest.InClusterConfig() provided by go-client could handle this instead. See the example in https://github.com/kubernetes/client-go/blob/master/examples/in-cluster-client-configuration/main.go
As a workaround, at the moment something like this is required to run k9s with Service Account's credentials:
MASTER="https://192.168.42.100:6443"
KUBECONFIG="${HOME}/.kube/config"
TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
CA_CRT="$(base64 -w 0 /var/run/secrets/kubernetes.io/serviceaccount/ca.crt)"
cat <<EOF > "${KUBECONFIG}"
apiVersion: v1
kind: Config
clusters:
- name: default-cluster
cluster:
certificate-authority-data: ${CA_CRT}
server: ${MASTER}
contexts:
- name: default-context
context:
cluster: default-cluster
namespace: default
user: default-user
current-context: default-context
users:
- name: default-user
user:
token: ${TOKEN}
EOF
In some use cases it's useful to run k9s inside the cluster in a pod.
It would be great to be able to directly use the Service Account's credentials. Currently k9s requires a $KUBECONFIG file. In other words, currently k9s cannot use credentials in /var/run/secrets/kubernetes.io/serviceaccount/ without first converting them to $KUBECONFIG.
Workaround is to create $KUBECONFIG before starting k9s, but that's boilerplate and requires a wrapper script for k9s (not nice).
The
rest.InClusterConfig()provided by go-client could handle this instead. See the example in https://github.com/kubernetes/client-go/blob/master/examples/in-cluster-client-configuration/main.goAs a workaround, at the moment something like this is required to run k9s with Service Account's credentials: