I have created a cluster using K3s and I have gotten config file below
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: XX_REPLACE_WITH_YOUR_CERTIFICATE_AUTHORITY_DATA_XX
server: https://XX_REPLACE_WITH_YOUR_CLUSTER_IP_XX:6443
name: default
contexts:
- context:
cluster: default
user: default
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
user:
client-certificate-data: XX_REPLACE_WITH_YOUR_CLIENT_CERTIFICATE_DATA_XX
client-key-data: XX_REPLACE_WITH_YOUR_CLIENT_KEY_DATA_XX
I want to connect the cluster using postman for example
https://{ClusterIP}:6443/api/v1/namespaces/nginx/configmaps/app-config
but in a secure way I need to generate a cert and key in .pem format how to do that ?
If you are asking about extracting certificates from the configuration file (it's a little unclear from your question):
The certificate and key in your kubeconfig file are already in .pem format; you just need to extract the data. Using
yq, you can do this to get the certificate:And to get the key: