Kubernetes Deployment 配置详解:dw-authz 服务部署

以下是一个 Kubernetes Deployment 配置文件的示例,用于部署名为 dw-authz 的服务:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dw-authz
  labels:
    app: dw
spec:
  selector:
    matchLabels:
      app: dw
      tier: authz
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: dw
        tier: authz
    spec:
      nodeName: yunwang-ityun-k8s01
      serviceAccountName: dw-configmap
      containers:
        #- image: registry.paas/cmss/identity-authz-server:2023-07-20-14-1689834711
        - image: registry.paas/cmss/identity-authz-server:2023-07-20-20-1689854962
          name: dw-authz
          env:
            - name: current_namespace
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
            - containerPort: 19999
              name: authz
          volumeMounts:
            - mountPath: '/var/log/epic'
              name: authz-log
              subPath: dw-authz-server
            - mountPath: '/data'
              name: authz-share
              subPath: authz
      volumes:
        - name: authz-log
          hostPath:
            path: '/apps/docs'
        - name: authz-share
          hostPath:
            path: '/apps/logs'

环境变量

这段配置中的环境变量是在 spec.template.spec.containers.env 字段中定义的。例如,名为 current_namespace 的环境变量,其值通过 fieldRef 获取 metadata.namespace 字段的值。

环境变量的具体值取决于当前 Deployment 所在的命名空间。

其他配置

除了环境变量外,这段配置还包含了其他重要配置,例如:

  • 容器镜像: image: registry.paas/cmss/identity-authz-server:2023-07-20-20-1689854962 指定了容器镜像的地址和版本。
  • 端口映射: containerPort: 19999 定义了容器内部的端口号。
  • 卷挂载: volumeMounts 定义了容器挂载的卷,volumes 定义了卷的具体配置,例如 hostPath 用于将本地目录挂载到容器内部。

更多关于 Deployment 配置的信息,请参考 Kubernetes 官方文档。

Kubernetes Deployment 配置详解:dw-authz 服务部署

原文地址: https://www.cveoy.top/t/topic/qD73 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录