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

边栏推荐
- 走进微信小程序
- [Supplément linguistique c] déterminer quel jour est demain (date de demain)
- 单例模式的懒汉模式跟恶汉模式的区别
- String class
- AI college entrance examination volunteer filling: the gods of Dachang fight, and candidates pay to watch
- 字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
- Ring iron pronunciation, dynamic and noiseless, strong and brilliant, magic wave hifiair Bluetooth headset evaluation
- [kotlin] Introduction to higher-order functions
- 荣威 RX5 的「多一点」产品策略
- How to cancel automatic search and install device drivers for laptops
猜你喜欢

模板引擎Velocity 基礎
![[nodemon] app crashed - waiting for file changes before starting... resolvent](/img/ee/9830afd86e092851a2a906cb994949.png)
[nodemon] app crashed - waiting for file changes before starting... resolvent

Iommu/smmuv3 code analysis (10) page table operation

Today, at 14:00, 15 ICLR speakers from Hong Kong University, Beihang, Yale, Tsinghua University, Canada, etc. continue!

【C补充】【字符串】按日期排序显示一个月的日程

Stegano in the world of attack and defense

Kali install Nessus

Buuctf gold III

Rhcsa Road

【C语言基础】12 字符串
随机推荐
Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid
存在安全隐患 起亚召回部分K3新能源
【C语言基础】12 字符串
英特尔开源深度学习工具库 OpenVINO,将加大与本土软硬件方合作,持续开放
中国锦纶长丝缝纫线发展预测与投资方向研究报告(2022版)
Determine whether the linked list is a palindrome linked list
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
Leetcode records - sort -215, 347, 451, 75
你还在用收费的文档管理工具?我这有更牛逼的选择!完全免费
【flask入门系列】Cookie与Session
sql刷题1050. 合作过至少三次的演员和导演
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Introduction to software engineering - Chapter 6 - detailed design
Bugku's file contains
中国生物降解塑料市场预测与投资战略报告(2022版)
判断链表是否是回文链表
libcurl下载文件的代码示例
巴比特 | 元宇宙每日必读:奈雪币、元宇宙乐园、虚拟股票游戏...奈雪的茶这波“操作拉满”的营销活动你看懂了吗?...
SQL注入漏洞(Mysql与MSSQL特性)
Redis Distributed Lock