{"id":1085,"date":"2021-07-05T10:31:57","date_gmt":"2021-07-05T02:31:57","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=1085"},"modified":"2023-04-07T09:56:36","modified_gmt":"2023-04-07T01:56:36","slug":"kubernetes-secret-concept-configuration","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2021\/07\/kubernetes-secret-concept-configuration\/","title":{"rendered":"kubernetes Secret \u6982\u5ff5\u914d\u7f6e\u3002"},"content":{"rendered":"
Secret \u662f\u4e00\u79cd\u5305\u542b\u5c11\u91cf\u654f\u611f\u4fe1\u606f\u4f8b\u5982\u5bc6\u7801\u3001\u4ee4\u724c\u6216\u5bc6\u94a5\u7684\u5bf9\u8c61\u3002 \u8fd9\u6837\u7684\u4fe1\u606f\u53ef\u80fd\u4f1a\u88ab\u653e\u5728 Pod \u89c4\u7ea6\u4e2d\u6216\u8005\u955c\u50cf\u4e2d\u3002 \u7528\u6237\u53ef\u4ee5\u521b\u5efa Secret\uff0c\u540c\u65f6\u7cfb\u7edf\u4e5f\u521b\u5efa\u4e86\u4e00\u4e9b Secret\u3002<\/p>\n \u6ce8\u610f\uff1a<\/strong><\/p>\n Kubernetes Secret \u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5b58\u50a8\u4e3a base64-\u7f16\u7801\u7684\u3001\u975e\u52a0\u5bc6\u7684\u5b57\u7b26\u4e32\u3002 \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u80fd\u591f\u8bbf\u95ee API \u7684\u4efb\u4f55\u4eba\uff0c\u6216\u8005\u80fd\u591f\u8bbf\u95ee Kubernetes \u4e0b\u5c42\u6570\u636e\u5b58\u50a8\uff08etcd\uff09 \u7684\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u4ee5\u660e\u6587\u5f62\u5f0f\u8bfb\u53d6\u8fd9\u4e9b\u6570\u636e\u3002 \u4e3a\u4e86\u80fd\u591f\u5b89\u5168\u5730\u4f7f\u7528 Secret\uff0c\u6211\u4eec\u5efa\u8bae\u4f60\uff08\u81f3\u5c11\uff09\uff1a<\/p>\n \u8981\u4f7f\u7528 Secret\uff0cPod \u9700\u8981\u5f15\u7528 Secret\u3002 Pod \u53ef\u4ee5\u7528\u4e09\u79cd\u65b9\u5f0f\u4e4b\u4e00\u6765\u4f7f\u7528 Secret\uff1a<\/p>\n Secret \u5bf9\u8c61\u7684\u540d\u79f0\u5fc5\u987b\u662f\u5408\u6cd5\u7684 DNS \u5b50\u57df\u540d<\/a>\u3002 \u5728\u4e3a\u521b\u5efa Secret \u7f16\u5199\u914d\u7f6e\u6587\u4ef6\u65f6\uff0c\u4f60\u53ef\u4ee5\u8bbe\u7f6e \u5728\u521b\u5efa Secret \u5bf9\u8c61\u65f6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Kubernetes \u63d0\u4f9b\u82e5\u5e72\u79cd\u5185\u7f6e\u7684\u7c7b\u578b\uff0c\u7528\u4e8e\u4e00\u4e9b\u5e38\u89c1\u7684\u4f7f\u7528\u573a\u666f\u3002 \u9488\u5bf9\u8fd9\u4e9b\u7c7b\u578b\uff0cKubernetes \u6240\u6267\u884c\u7684\u5408\u6cd5\u6027\u68c0\u67e5\u64cd\u4f5c\u4ee5\u53ca\u5bf9\u5176\u6240\u5b9e\u65bd\u7684\u9650\u5236\u5404\u4e0d\u76f8\u540c\u3002<\/p>\nSecret<\/code> \u5bf9\u8c61\u7c7b\u578b\u7528\u6765\u4fdd\u5b58\u654f\u611f\u4fe1\u606f\uff0c\u4f8b\u5982\u5bc6\u7801\u3001OAuth \u4ee4\u724c\u548c SSH \u5bc6\u94a5\u3002 \u5c06\u8fd9\u4e9b\u4fe1\u606f\u653e\u5728
secret<\/code> \u4e2d\u6bd4\u653e\u5728 Pod<\/a> \u7684\u5b9a\u4e49\u6216\u8005 \u5bb9\u5668\u955c\u50cf<\/a> \u4e2d\u6765\u8bf4\u66f4\u52a0\u5b89\u5168\u548c\u7075\u6d3b\u3002 \u53c2\u9605 Secret \u8bbe\u8ba1\u6587\u6863<\/a> \u83b7\u53d6\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n
\n
\n
Secret \u6982\u89c8<\/h2>\n
\n
data<\/code> \u4e0e\/\u6216
stringData<\/code> \u5b57\u6bb5\u3002
data<\/code> \u548c
stringData<\/code> \u5b57\u6bb5\u90fd\u662f\u53ef\u9009\u7684\u3002
data<\/code> \u5b57\u6bb5\u4e2d\u6240\u6709\u952e\u503c\u90fd\u5fc5\u987b\u662f base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u4e0d\u5e0c\u671b\u6267\u884c\u8fd9\u79cd base64 \u5b57\u7b26\u4e32\u7684\u8f6c\u6362\u64cd\u4f5c\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u8bbe\u7f6e
stringData<\/code> \u5b57\u6bb5\uff0c\u5176\u4e2d\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5176\u53d6\u503c\u3002<\/p>\n
Secret \u7684\u7c7b\u578b<\/h2>\n
Secret<\/code><\/a> \u8d44\u6e90\u7684
type<\/code> \u5b57\u6bb5\uff0c\u6216\u8005\u4e0e\u5176\u7b49\u4ef7\u7684
kubectl<\/code> \u547d\u4ee4\u884c\u53c2\u6570\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u4e3a\u5176\u8bbe\u7f6e\u7c7b\u578b\u3002 Secret \u7684\u7c7b\u578b\u7528\u6765\u5e2e\u52a9\u7f16\u5199\u7a0b\u5e8f\u5904\u7406 Secret \u6570\u636e\u3002<\/p>\n