当前位置:网站首页>Combine pod identity in aks and secret in CSI driver mount key vault
Combine pod identity in aks and secret in CSI driver mount key vault
2022-06-24 22:41:00 【mxy00000】
In a previous article, I introduced in AKS How to get through CSI driver This add on, take secret Automatically mount To pod in , By way of secret Put it in key vault Let the application automatically get , It can well protect the security of some confidential information
stay AKS Pass through CSI Driver mount key vault Medium secret
But there is a small problem with this approach , Before that, we used service principal mount Of secret, This requires that we need to AKS Create a secret, Inside storage service principal Of id and pwd, In general, if AKS The is responsible for operation and maintenance team Unified management , If the application team does not have permission , There is no problem with this approach , But if the application team also has AKS jurisdiction , This is not very good , Because it is possible that people in the application team may have permission to view secret In the value of the
So to avoid this , We can also use pod identity combination managed service identity Get all together token The steps are completely left to the backstage Azure complete , There is no need to have any obvious pwd Such traces
Let's take a look at the specific measures , This demo There are many preconditions required , If the steps are not covered in this article , You can refer to the following two articles
stay AKS Pass through CSI Driver mount key vault Medium secret
stay AKS Use in pod identity obtain token - practice
Environmental preparation :
1. AKS Cluster * 1
2. User assigned managed identity * 1
3. Key Vault * 1
4. Kubectl client * 1
precondition :
1. Create good AKS Cluster
2. Create good Key Vault
3. stay Key Vault Ready for testing secret
4. Create a test User assigned managed identity
5. by AKS Cluster Enable CSI driver add on
6. stay AKS Cluster Deploy pod identity component
Actual operation
to identity Authorized access secret
First, first User assigned managed identity Authorized access Key Vault Medium secret

Demo That's it. User assigned managed identity

Get ready yaml file
The next step is to prepare pod identity Medium Azure Identity and binding Deployment files and pod Deployment file for
AzureIdentity
apiVersion
"aadpodidentity.k8s.io/v1"
kind
AzureIdentity
metadata
name
<any-name>
spec
type
0
resourceID
/subscriptions/<subid>/resourcegroups/<resourcegroup>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<idname>
clientID
<clientid>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
AzureIdentityBinding
apiVersion
"aadpodidentity.k8s.io/v1"
kind
AzureIdentityBinding
metadata
name
<any-name>
spec
azureIdentity
<name of the AzureIdentity created in previous step>
selector
<label value to match in your pod>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
Get ready SecretProviderClass Of yaml
apiVersion
secrets-store.csi.x-k8s.io/v1
kind
SecretProviderClass
metadata
name
azure-kvname-podid
spec
provider
azure
parameters
usePodIdentity
"true"
keyvaultName
"kvname"
objects
array:
- |
objectName: secret1
objectType: secret # object types: secret, key or cert
objectVersion: "" # [OPTIONAL] object versions, default to latest if empty
- |
objectName: key1
objectType: key
objectVersion: ""
tenantId
"tid"
# the tenant ID of the KeyVault
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
Finally, prepare for the test pod yaml
apiVersion
v1
kind
Pod
metadata
labels
app
podidentitykeyvault
aadpodidbinding
keyvaultdemoselector
name
podidentitykeyvault
spec
containers
image
***
livenessProbe
httpGet
path
/
port
80
initialDelaySeconds
30
periodSeconds
20
timeoutSeconds
10
failureThreshold
3
imagePullPolicy
Always
name
podidentitysecret
volumeMounts
mountPath
"/mnt/secrets-store"
name
secrets-store-inline
readOnly
true
volumes
csi
driver
secrets-store.csi.k8s.io
readOnly
true
volumeAttributes
secretProviderClass
"azure-kv-demo"
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.
Start deployment
kubectl apply -f .\AzureIdentity.yml
kubectl apply -f .\AzureIdentityBinding.yml
- 1.
- 2.

The deployment process will not be described in detail , But you can see that after deployment ,Pod Run normally , And you can get secret

azure assigned identity It is also created normally
kubectl get azureassignedidentity
- 1.

边栏推荐
- Use of selector for NiO multiplexing
- Chapter 10 project stakeholder management
- Web security XSS foundation 06
- Raspberry pie preliminary use
- Learning bit segment (1)
- Principle of IP routing
- Leetcode: calculate the number of elements less than the current element on the right (sortedlist+bisect\u left)
- 网上立案流程
- HTTP的缓存控制
- Firewall working principle and detailed conversation table
猜你喜欢

Uncover the secret of station B. is it true that programmers wear women's clothes and knock code more efficiently?

NiO, bio, AIO

Common voting governance in Dao

Leetcode: push domino (domino simulation)
How to solve the problem that the computer suddenly can't connect to WiFi
CA Zhouji - the first lesson in 2022 rust

VRRP skills topic
![[QT] QT event handling](/img/48/14a5491307fee1c99434d6cb308337.jpg)
[QT] QT event handling

CDN principle

Row and column differences in matrix construction of DX HLSL and GL glsl
随机推荐
Docker installs MySQL 8.0. Detailed steps
Common voting governance in Dao
Concurrency of heap memory allocation
[ingénierie logicielle] points clés à la fin de la période
Online filing process
干货丨产品的可行性分析要从哪几个方面入手?
Description of software version selection of kt6368a Bluetooth dual-mode transparent chip
Use of selector for NiO multiplexing
AQS源码分析
socket done
interrupt、interrupted 、isInterrupted 区别
Envoy obtain the real IP address of the client
关于自动控制原理资料更新
A pit in try with resources
The core concept of JMM: happens before principle
Servlet details
NIO 零拷贝
Docker 安装 MySQL 8.0,详细步骤
The ktp900f mobile download program of the fail safe mobile panel prompts that the download cannot be performed, and the target device is running or not in the transmission mode
Principles of Ethernet port mirroring, link aggregation and VLAN Technology