首页 文章 精选 留言 我的

精选列表

搜索[storage],共4944篇文章
优秀的个人博客,低调大师

Kubernetes - 6.2 Config and Storage - Secrets

什么是Secret 通过Secret可以将敏感信息注入到Pod中的容器,一般用于存储访问私有仓库的账号密码、TLS证书、Token等。Secret可以做为容器依附在Pod中使用,或者可以通过环境变量引入。这是比直接使用ConfigMap更加安全的方式,降低敏感数据直接暴露给未授权用户的风险。 Secret 基本操作 通过kubectl create secret kubectl create secret generic nginx-secret --from-literal=password=123456 通过yaml资源配置清单先转换为Base64编码echo -n "123456" |base64 输出 MTIzNDU2kubectl apply -f nginx-secret.yaml apiVersion: v1 kind: Secret metadata: name: nginx-secret type: Opaque data: password: MTIzNDU2 Secret 类型 generic 从文件、目录或命令行参数中创建Secret。docker-registry 创建针对与Docker Registory身份验证的账号密码。tls 从输入的密钥对中创建TLS Secret,密钥对必须提前申请好,公钥需要采用.PEM编码并匹配对应的私钥。 参数说明--from-file 或 --from-env-file 指定包含一个或多个配置文件的目录的路径--from-literal 指定一对从命令行输入的键值对 Secret作为数据卷被Pod挂载使用 kubectl apply -f nginx-pod-secret.yaml apiVersion: v1 kind: Secret metadata: name: nginx-secret type: Opaque data: password: MTIzNDU2 apiVersion: v1 kind: Pod metadata: name: nginx-pod labels: app: nginx spec: volumes: - name: secret-volume secret: secretName: nginx-secret containers: - name: nginx image: nginx:1.16 volumeMounts: - name: secret-volume readOnly: true mountPath: "/etc/secret-volume" Secret作为TLS证书被Ingress调用 kubectl create secret tls ingress-certificate --key tls.key --cert tls.crtIngress的YAML资源定义清单 tls: - hosts: - nginx.com secretName: ingress-certificate 使用技巧 对于安全保密等级较高的数据建议使用Secret进行存储及被其他资源所调用。

优秀的个人博客,低调大师

Kubernetes - 6.1 Config and Storage - ConfigMap

什么是ConfigMap ConfigMap为Pod中的容器提供了配置文件、环境变量等非敏感信息,通过ConfigMap可以将Pod和其他组件分开,这将使得Pod更加有移植性,使得配置更加容器更改及管理,也使得Pod更加规范。 Config基本操作 通过kubectl create configmapkubectl create configmap nginx-configmap --from-literal=password=123456 通过yaml资源配置清单kubectl apply -f nginx-configmap.yaml apiVersion: v1 kind: List metadata: items: - apiVersion: v1 data: password: "123456" kind: ConfigMap metadata: name: nginx-configmap 通过kubectl get configmap查看详细信息 通过kubectl describe configmap查看详细信息 ConfigMap作为存储卷被Pod调用 创建ConfigMapkubectl create configmap database-config --from-literal=user=root --from-literal=password=123456 通过YAML资源定义清单创建Pod并绑定ConfigMap为存储卷kubectl apply -f nginx-pod-configmap-volume.yaml apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx image: nginx:1.16 volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: database-config 查看Pod容器挂载的ConfigMap存储卷kubectl exec -it nginx-pod /bin/bash 查看Pod详细信息,挂载了ConfigMap类型的Volumeskubectl describe pod nginx-pod ConfigMap作为环境变量被Pod调用 kubectl create configmap database-config --from-literal=user=root --from-literal=password=123456kubectl create configmap env-config --from-literal=LOG_LEVEL=ERROR kubectl apply -f nginx-pod-configmap-env.yaml apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx image: nginx:1.16 env: - name: DB_USER_CONFIG valueFrom: configMapKeyRef: name: database-config key: user - name: DB_PASSWORD_CONFIG valueFrom: configMapKeyRef: name: database-config key: password envFrom: - configMapRef: name: env-config 查看Pod容器的环境变量kubectl exec -it nginx-pod /bin/bash 查看Pod容器详细信息kubectl describe pod nginx-pod Config注意的事项 ConfigMap文件大小限制: 1MB (etcd的限制) ConfigMap必须在Pod引用它之前创建

优秀的个人博客,低调大师

Kubernetes - 6.4 Config and Storage - Serivce Account

什么是Service Account Service Account是为了解决Kubernetes集群内部资源认证问题而诞生,例如Pod的进程想调用Kubernetes API或者其他外部服务。 Service Account基本操作 通过kubectl创建ServiceAccountkubectl create sa nginx-sa 可以见到创建了ServiceAccount之后也自动创建了Secret对象并自动引用了 将Service Account绑定到Pod kubectl apply -f nginx-pod-sa.yaml apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx image: nginx:1.16 serviceAccountName: nginx-sa

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册