当前位置:网站首页>In aks, use secret in CSI driver mount key vault
In aks, use secret in CSI driver mount key vault
2022-07-01 16:58:00 【mxy00000】
What will this article introduce , You should be able to see it in the title , This article mainly introduces how to AKS Lieutenant general Azure Key Vault Medium secret mount To storage in , This scenario should be regarded as a very standard security design , For example, some confidential information is generally recommended to be placed in Key Vault in , It would be safer , for instance , Database or application username and pwd, Put it in Key Vault in , And then let pod Auto read key vault Information in , This can avoid the risk of information disclosure to the greatest extent
And if you want to achieve this , You need to use the content introduced today , Mainly through CSI driver To achieve , It used to be called Flex Volume, obtain secret The content in must have permission , There are many ways to get authorization , Include service principal,pod identity,vmss identity Many other kinds , This time, we mainly use service principal The way
First of all, I will briefly introduce the contents that need to be prepared , It contains so many things
- One AKS Cluster
- One SP, And corresponding client id and pwd
- One Key Vault, stay Key Vault Configure some in secret
- add to Access Policy to SP Authorized access secret
- For deployment yaml file
establish cluster,service principal(SP) as well as key vault I won't introduce the steps of
Go straight to work , Take a look first key vault The following secret
Now add a access policy, to service principal grant secret Of get,list jurisdiction
Then first K8S Create a secret, This secret Will contain service principal Of id and pwd,csi driver Will read this secret And then through service principal Of id and pwd Get token, Then pull key vault Inside secret
kubectl create secret generic keyvaultsecret --from -literal clientid =<AZURE_CLIENT_ID> --from -literal clientsecret =<AZURE_CLIENT_SECRET>
kubectl label secret keyvaultsecret secrets-store.csi.k8s.io /used = true
- 1.
- 2.
Next, prepare for deployment yaml file ,yaml There are two main documents
- SecretProviderClass yaml, Used to describe what to get secret And how to get secret
- App yaml, Regular application deployment yaml, contain mountpath And the use of secret
SecretProviderClass yaml
apiVersion secrets-store.csi.x-k8s.io/v1
kind SecretProviderClass
metadata
name "spc-keyvault"
namespace "default"
spec
provider azure
parameters
usePodIdentity "false"
useVMManagedIdentity "false"
userAssignedIdentityID "***" # Service Principal ID
keyvaultName "mxyvault"
objects
array:
- |
objectName: username
objectType: secret
- |
objectName: userpwd
objectType: secret
tenantId "****" # tenant ID
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
App yaml
apiVersion apps/v1
kind Deployment
metadata
labels
app apachesecret
name apachesecret
spec
replicas 2
selector
matchLabels
app apachesecret
strategy
rollingUpdate
maxSurge 1
maxUnavailable 1
type RollingUpdate
template
metadata
labels
app apachesecret
name apachesecret
spec
containers
image *****
livenessProbe
httpGet
path /
port 80
initialDelaySeconds 30
periodSeconds 20
timeoutSeconds 10
failureThreshold 3
imagePullPolicy Always
name apachesecret
volumeMounts
mountPath "/mnt/secrets-store"
name secrets-store-inline
readOnly true
volumes
csi
driver secrets-store.csi.k8s.io
nodePublishSecretRef
name keyvaultsecret
readOnly true
volumeAttributes
secretProviderClass "spc-keyvault"
name "secrets-store-inline"
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
It's a simple one demo It's almost done , Next, before deployment , You need to give it first AKS Turn on add on, otherwise secret provider class This resource Will not be recognized
az aks enable-addons --addons azure-keyvault-secrets-provider --name myAKSCluster --resource -group myResourceGroup
- 1.
Then you can start deployment
kubectl apply -f "D:\UserData\Desktop\ApacheSecretProviderClassyml.yaml"
kubectl apply -f "D:\UserData\Desktop\ApacheSecretDeployment.yml"
- 1.
- 2.
You can see pod It's already running
kubectl get po
- 1.
And into pod in , You can also see secret Have succeeded pull down
边栏推荐
- 字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
- Template engine velocity Foundation
- SQL question brushing 1050 Actors and directors who have worked together at least three times
- Please, stop painting star! This has nothing to do with patriotism!
- unity3d扩展工具栏
- AI高考志愿填报:大厂神仙打架,考生付费围观
- Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
- 6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
- Bugku's file contains
- Iommu/smmuv3 code analysis (10) page table operation
猜你喜欢
sql刷题627. 变更性别
美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告
换掉UUID,NanoID更快更安全!
Leetcode 77 combination -- backtracking method
SystemVerilog-结构体(二)
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
Internet News: "20220222" get together to get licenses; Many products of Jimi have been affirmed by consumers; Starbucks was fined for using expired ingredients in two stores
Basic use of MySQL
sql刷题1050. 合作过至少三次的演员和导演
String类
随机推荐
[Supplément linguistique c] déterminer quel jour est demain (date de demain)
Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid
AI高考志愿填报:大厂神仙打架,考生付费围观
Jojogan practice
Template Engine Velocity Foundation
redis -- 数据类型及操作
SQL注入漏洞(Mysql与MSSQL特性)
P2592 [zjoi2008] birthday party (DP)
Babbitt | yuan universe daily must read: Naixue coin, Yuan universe paradise, virtual stock game Do you understand Naixue's tea's marketing campaign of "operation pull full"
【flask入门系列】Cookie与Session
走进微信小程序
中国生物降解塑料市场预测与投资战略报告(2022版)
【PyG】文档总结以及项目经验(持续更新
Transition technology from IPv4 to IPv6
String class
求求你们,别再刷 Star 了!这跟“爱国”没关系!
How to restore the system of Sony laptop
unity3d扩展工具栏
独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作
China benzene hydrogenation Market Research and investment forecast report (2022 Edition)