当前位置:网站首页>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

边栏推荐
- P2893 [USACO08FEB] Making the Grade G(dp&优先队列)
- Research and investment strategy report of China's sodium sulfate industry (2022 Edition)
- 智能运维实战:银行业务流程及单笔交易追踪
- 求求你们,别再刷 Star 了!这跟“爱国”没关系!
- 如何使用 etcd 实现分布式 /etc 目录
- SQL question brushing 584 Looking for user references
- unity3d扩展工具栏
- [nodemon] app crashed - waiting for file changes before starting... resolvent
- [wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
- Basic usage of Frida
猜你喜欢
![[mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code](/img/de/1f572c62a0d034da9a8acb5c2f9602.jpg)
[mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code
![[pyg] document summary and project experience (continuously updated](/img/b4/75da8c3e657069be4e3e3bfd5b2dc0.png)
[pyg] document summary and project experience (continuously updated

Jojogan practice

Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!

Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022

嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!

Machine learning 11 clustering, outlier discrimination

独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作

多线程并发之CountDownLatch阻塞等待

Computed property “xxx“ was assigned to but it has no setter.
随机推荐
判断二叉树是否为二叉搜索树
Research and investment strategy report of neutral protease industry in China (2022 Edition)
China benzene hydrogenation Market Research and investment forecast report (2022 Edition)
今天14:00 | 港大、北航、耶鲁、清华、加大等15位ICLR一作讲者精彩继续!
[pyg] document summary and project experience (continuously updated
redis -- 数据类型及操作
Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers
P2893 [usaco08feb] making the grade g (DP & priority queue)
Are you still using charged document management tools? I have a better choice! Completely free
阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外
How to maintain the laptop battery
在MeterSphere接口测试中如何使用JMeter函数和MockJS函数
Today, at 14:00, 15 ICLR speakers from Hong Kong University, Beihang, Yale, Tsinghua University, Canada, etc. continue!
sql刷题627. 变更性别
【C语言基础】12 字符串
SQL question brushing 1050 Actors and directors who have worked together at least three times
求求你们,别再刷 Star 了!这跟“爱国”没关系!
[wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
游戏行业安全选择游戏盾,效果怎么样?