I have created self-signed user certificates for my kubernetes cluster and now want to distribute respective kubeconfig files to the users.
How to I transform the .crt and .key files I used for the process to kubeconfig inline format?
Here is a redacted sample inline representation of the crt file:
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMrekNDQWVPZ0F3SUJBZ0lNRlFwTllCZ2hwSWFBclNJYU1BMEdDU3FHU0liM0RRRUJDd1VBTUJVeEV6QVIKQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13SGhjTk1UZ3dNVEUwTVRNeU9ERTVXaGNOTWpnd01URTBNVE15T0RFNQpXakFyTVJjd0ZRWURWUVFLRXc1emVYTjBaVzA2YldGemRHVnljekVRTUE0R0ExVUVBeE1IYTNWaVpXTm1aekNDCkFTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTWkraGFFb1d6Mk8yYUN5d3JhOHo4UHAKem9jUTBHK2JnTVFGQSttZzZCQkhRWCt1UFhQbVBpM2FOSjBmcXBsM0sySjkvbkNodVo4T0JRT1ZHa3ZGaDdIbApWQmR6WG9qOHZ6ZUplUko4SFBlNDV5NXJYQnZtUkRUYUhGSWJ1ZWdGYzlYRFNCemtob21jYTlKOHdXSS9nUHdpCnNaaTczd2o1TVdtbnk3MlRyQ1RuZktUTzVXY1IyT2txRGNCalhPb2thWTFqckkrSlpSdmpIa1FobnB2bTNrWW4KVnNo-----------xdTZiS1k1WVFYYUwvNXNRcTFKNXMyVnh1ckRaQ2c5anA4ZlQrMEUzbWwvM1lkTEF0MjI0NG1Ec1MKdFFjM2k5Nk8rM0xFeU90REsraW5vKzB1WnZWZ0lrazZhOG9LS0hxaks5b21oOWg3WjE1UjVwWkxIa3dTVmluYwpLbHZGOUt4WXJrekdidmFiRUZZd0p1ejFTdW02ZkJ4dDQ5THkvWDFKQkZ1K1pnWDFPWjdnM2ZPeGt3WWdtVVBnCmt5Mmx1Zk1MZWI2SzdwOVdkaUxsUFAyRWk4aG9CWTNXQk9UQk1kcXY1Wm01VWpUUm9sZkIrTXZwTEp0ZlFOST0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
Simply encode it with Base 64 :
cat mycert.crt | base64 -w0
Secrets are stored as base64, see: https://kubernetes.io/docs/concepts/configuration/secret/
Or the example from here: https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
cat server.csr | base64 | tr -d '\n'
cat mycert.crt|base64 -w0 better
-w, --wrap=COLS wrap encoded lines after COLS character (default 76). Use 0 to disable line wrapping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With