当前位置:网站首页>No one wants to tell the truth about kubernetes secret
No one wants to tell the truth about kubernetes secret
2022-07-28 08:49:00 【Attack cloud primordial】
You really need Secret Objects? ?

Many people think that you should always use Kubernetes Secrets. When you start using Kubernetes when , I think that's right. Secret Objects The need is obvious .
But after a short time and many projects , I began to doubt its actual needs in deploying applications to production environments . Let's elaborate on .
What is? Secret
I hope we first clearly understand Kubernetes Upper Secret What is the object . I think the official document gives a clear definition .
Secret It contains a small amount of sensitive data ( For example, password 、 Token or key ) The object of . Such information may be placed in other ways Pod Spec Or container image . Use Secret This means that you don't need to include secret data in your application code .
Let's take a look at one Secret YAML Sample file :
apiVersion: v1
kind: Secret
metadata:
name: mysecret
namespace: default
type: Opaque
data:
username: YWRtaW4=
password: MWYyZDFlMmU2N2Rm
Kubernetes The mechanism ensures Secret Data security
Secret It has the following characteristics :
- One pod Unable to access another pod Of Secret.
- If one is arranged on this node pod And need it , Then this node can use Secret.
- Secret The maximum allowed size of can only be 1 MB. This helps protect apiserver Memory resources and kubelet Free from abuse .
- default View Roles are not granted to Secrets Access rights of .
These are Kubernetes To provide Secret Some of the main security mechanisms implemented by the security baseline .
About production Secret It's the hard truth
Now let's look at it from the perspective of the attacker , How things are .
Let's start with Kubernetes The vulnerabilities mentioned in the document begin .
By default ,Kubernetes Secret Stored unencrypted in API The underlying data store of the server (etcd) in .
actually , The secret data is base64 Coded . But you only need to apply the reverse base64 You can get pure data .
Any possession API Anyone with access can retrieve or modify Secret, Anyone who has access to etcd People can also .
Besides , Anyone who has permission to create in the namespace Pod Anyone can use this access right to read any in the namespace Secret; This includes indirect access , For example, create Deployment The ability of .
To solve these problems ,Kubernetes Some practices are recommended to ensure Secret Data security .
Kubernetes What suggestions does the document have ?
To avoid these pitfalls , The document provides some suggestions .
First , You should be Secrets Enable static encryption .
secondly , You should enable or configure restrict read and write Secret Of RBAC The rules .
Last , It should also be used RBAC And other mechanisms to limit which principals are allowed to create new Secret Or replace the existing Secret.
In production Secret problem
in other words , Some problems still exist , When we consider them in production , Things will surface . Let's see .
- GitOps Has controlled the way we create and maintain infrastructure . therefore , If we need to create one Secret To store sensitive data , Do we want to add it to Ops Repository ?
If you don't do that , So users ( Developer 、 Administrator, etc ) Will have to deal with these secrets through imperative commands . If this is done , Then it opens the door for different types of attacks .
- By the same pod In the container , You can visit pod Any secrets in .
The first 4 The problem is DevOps The biggest concern : How we are in Kubernetes Available on the cluster Secret data , Follow at the same time GitOps Best practices .
Here are some alternatives I have found so far .
1. Hashicorp vault :
HashiCorp Vault Is an identity based secret and encryption management system .Vault Provide encryption services controlled by authentication and authorization methods .
https://www.vaultproject.io/
Vault The beauty of is that it is an open source tool . You can set up your own instance and manage it yourself . You can also rely on their cloud platform .
2. Cloud provider Secret Managers
AWS、GCP and Azure Wait for cloud providers to provide Secret Manager, It can be used to protect the security of secret data and Kubernetes Use them on .
GCP Yes Google Secret Manager. This tutorial shows how to start in GKE(Kubernetes For Google) Upper use Google Secret Manager.
https://cloud.google.com/secret-manager
AWS Provide AWS Secret Manager, You can use it to manage your secret data .
https://docs.aws.amazon.com/secretsmanager/latest/userguide/integrating_csi_driver.html
Azure So it is with , It puts forward Key Vault, It can be done with Azure Kubernetes Service Integrate .
https://medium.com/swlh/integrate-azure-key-vault-with-azure-kubernetes-service-1a8740429bea
There are many other solutions that can provide the same services and better solve these problems .
Conclusion
We often say that none of them 100% Safe system , But as a DevOps And software engineers , Have the responsibility to find 、 Build and implement best practices , To improve infrastructure and provide customers with more secure systems .
Kubernetes Secret Still useful ( For example, when accessing private Docker When Repository ), But we must combine them with more advanced tools and services to ensure system security .
边栏推荐
- 2022 Niuke multi school second problem solving Report
- The current value of uniapp's swiper dynamic setting does not take effect solution
- 【OpenCV】生成透明的PNG图像
- 2018年1月西邻雪山自驾游攻略
- HCIP第八天
- PHP基础知识 - PHP 使用 MySQLI
- 第2章-2 计算分段函数[1]
- MySQL how to add users and set permissions?
- 49-OpenCv深入分析轮廓
- Recruiting talents, gbase high-end talent recruitment in progress
猜你喜欢

Vk1620 temperature controller / smart meter LED digital display driver chip 3/4-wire interface with built-in RC oscillator to provide technical support

Service current limiting and fusing of micro service architecture Sentinel

C #, introductory tutorial -- debugging skills and logical error probe technology and source code when the program is running

Gbase appears in Unicom cloud Tour (Sichuan Station) to professionally empower cloud ecology

竞赛:糖尿病遗传风险检测挑战赛(科大讯飞)

1w5字详细介绍分布式系统的那些技术方案

SQL Server查询结果导出到EXCEL表格

Top all major platforms, 22 versions of interview core knowledge analysis notes, strong on the list

49-OpenCv深入分析轮廓

Hcip day 8
随机推荐
GB/T 41479-2022信息安全技术 网络数据处理安全要求 导图概览
5张图告诉你:同样是职场人,差距怎么这么大?
'global event bus' &' message subscription and Publishing '
Day112.尚医通:手机验证码登录功能
oracle sql 问题
The five pictures tell you: why is there such a big gap between people in the workplace?
Why can ThreadLocal achieve thread isolation?
Flink Window&Time 原理
图片批处理|必备小技能
PHP基础知识 - PHP 使用 PDO
说透缓存一致性与内存屏障
Gb/t 41479-2022 information security technology network data processing security requirements map overview
阻塞队列LinkedBlockingQueue 源码解析
How CI framework integrates Smarty templates
谷歌 Material Design 的文本框为什么没人用?
HCIP第九天_BGP实验
Chapter 2-14 sum integer segments
Flink window & time principle
Blog building 7: Hugo
Introduction of functions in C language (blood Book 20000 words!!!)