将 SSL .crt 转换为 kubernetes 内联格式
Transform SSL .crt to kubernetes inline format
我已经为我的 kubernetes 集群创建了自签名用户证书,现在想将相应的 kubeconfig 文件分发给用户。
如何将我用于进程的 .crt 和 .key 文件转换为 kubeconfig 内联格式?
这是 crt 文件的编辑示例内联表示:
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMrekNDQWVPZ0F3SUJBZ0lNRlFwTllCZ2hwSWFBclNJYU1BMEdDU3FHU0liM0RRRUJDd1VBTUJVeEV6QVIKQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13SGhjTk1UZ3dNVEUwTVRNeU9ERTVXaGNOTWpnd01URTBNVE15T0RFNQpXakFyTVJjd0ZRWURWUVFLRXc1emVYTjBaVzA2YldGemRHVnljekVRTUE0R0ExVUVBeE1IYTNWaVpXTm1aekNDCkFTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTWkraGFFb1d6Mk8yYUN5d3JhOHo4UHAKem9jUTBHK2JnTVFGQSttZzZCQkhRWCt1UFhQbVBpM2FOSjBmcXBsM0sySjkvbkNodVo4T0JRT1ZHa3ZGaDdIbApWQmR6WG9qOHZ6ZUplUko4SFBlNDV5NXJYQnZtUkRUYUhGSWJ1ZWdGYzlYRFNCemtob21jYTlKOHdXSS9nUHdpCnNaaTczd2o1TVdtbnk3MlRyQ1RuZktUTzVXY1IyT2txRGNCalhPb2thWTFqckkrSlpSdmpIa1FobnB2bTNrWW4KVnNo-----------xdTZiS1k1WVFYYUwvNXNRcTFKNXMyVnh1ckRaQ2c5anA4ZlQrMEUzbWwvM1lkTEF0MjI0NG1Ec1MKdFFjM2k5Nk8rM0xFeU90REsraW5vKzB1WnZWZ0lrazZhOG9LS0hxaks5b21oOWg3WjE1UjVwWkxIa3dTVmluYwpLbHZGOUt4WXJrekdidmFiRUZZd0p1ejFTdW02ZkJ4dDQ5THkvWDFKQkZ1K1pnWDFPWjdnM2ZPeGt3WWdtVVBnCmt5Mmx1Zk1MZWI2SzdwOVdkaUxsUFAyRWk4aG9CWTNXQk9UQk1kcXY1Wm01VWpUUm9sZkIrTXZwTEp0ZlFOST0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
只需使用 Base 64 对其进行编码即可:
cat mycert.crt | base64 -w0
机密以 base64 格式存储,请参阅:
https://kubernetes.io/docs/concepts/configuration/secret/
或此处的示例:
https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
cat server.csr | base64 | tr -d '\n'
cat mycert.crt|base64 -w0 更好
-w, --wrap=COLS 在 COLS 字符后换行编码行(默认 76)。
使用 0 禁用换行
我已经为我的 kubernetes 集群创建了自签名用户证书,现在想将相应的 kubeconfig 文件分发给用户。
如何将我用于进程的 .crt 和 .key 文件转换为 kubeconfig 内联格式?
这是 crt 文件的编辑示例内联表示:
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMrekNDQWVPZ0F3SUJBZ0lNRlFwTllCZ2hwSWFBclNJYU1BMEdDU3FHU0liM0RRRUJDd1VBTUJVeEV6QVIKQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13SGhjTk1UZ3dNVEUwTVRNeU9ERTVXaGNOTWpnd01URTBNVE15T0RFNQpXakFyTVJjd0ZRWURWUVFLRXc1emVYTjBaVzA2YldGemRHVnljekVRTUE0R0ExVUVBeE1IYTNWaVpXTm1aekNDCkFTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTWkraGFFb1d6Mk8yYUN5d3JhOHo4UHAKem9jUTBHK2JnTVFGQSttZzZCQkhRWCt1UFhQbVBpM2FOSjBmcXBsM0sySjkvbkNodVo4T0JRT1ZHa3ZGaDdIbApWQmR6WG9qOHZ6ZUplUko4SFBlNDV5NXJYQnZtUkRUYUhGSWJ1ZWdGYzlYRFNCemtob21jYTlKOHdXSS9nUHdpCnNaaTczd2o1TVdtbnk3MlRyQ1RuZktUTzVXY1IyT2txRGNCalhPb2thWTFqckkrSlpSdmpIa1FobnB2bTNrWW4KVnNo-----------xdTZiS1k1WVFYYUwvNXNRcTFKNXMyVnh1ckRaQ2c5anA4ZlQrMEUzbWwvM1lkTEF0MjI0NG1Ec1MKdFFjM2k5Nk8rM0xFeU90REsraW5vKzB1WnZWZ0lrazZhOG9LS0hxaks5b21oOWg3WjE1UjVwWkxIa3dTVmluYwpLbHZGOUt4WXJrekdidmFiRUZZd0p1ejFTdW02ZkJ4dDQ5THkvWDFKQkZ1K1pnWDFPWjdnM2ZPeGt3WWdtVVBnCmt5Mmx1Zk1MZWI2SzdwOVdkaUxsUFAyRWk4aG9CWTNXQk9UQk1kcXY1Wm01VWpUUm9sZkIrTXZwTEp0ZlFOST0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
只需使用 Base 64 对其进行编码即可:
cat mycert.crt | base64 -w0
机密以 base64 格式存储,请参阅: https://kubernetes.io/docs/concepts/configuration/secret/
或此处的示例: https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
cat server.csr | base64 | tr -d '\n'
cat mycert.crt|base64 -w0 更好
-w, --wrap=COLS 在 COLS 字符后换行编码行(默认 76)。 使用 0 禁用换行