Sign inSign up

bubua12/auto-config-controller

By bubua12

•Updated 7 months ago

Add SVC exposure to the Java deploy under a specific namespace with host + NodePort

Image
0

409

bubua12/auto-config-controller repository overview

⁠🚀 Kubernetes Deployment Handler

Go Version Kubernetes License

一个基于 client-go 的 Kubernetes Deployment 监控控制器


⁠📋 Kubernetes 部署

自动处理 syncplant-backend 名称空间下的 deploy,后端自动添加 NodePort 的 svc 并使用主机:NodePort注册到 Nacos

# 创建专门的 ServiceAccount,放在devops下
apiVersion: v1
kind: ServiceAccount
metadata:
  name: syncplant-controller-sa
  namespace: devops
---
# 创建 ClusterRole 因为操作跨 namespace 的 deployment/service/pod
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: syncplant-controller-cr
rules:
  - apiGroups: [ "apps" ]
    resources: [ "deployments" ]
    verbs: [ "get", "list", "watch", "update", "patch" ]

  - apiGroups: [ "" ]
    resources: [ "services", "pods" ]
    verbs: [ "get", "list", "watch", "create", "update", "patch" ]
---
# 使用 ClusterRoleBinding,把权限只绑定到这个 SA(安全)
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: syncplant-controller-crb
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: syncplant-controller-cr
subjects:
  - kind: ServiceAccount
    name: syncplant-controller-sa
    namespace: devops   # Controller 所在的 namespace
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: syncplant-svc-controller
  namespace: devops
spec:
  replicas: 1
  selector:
    matchLabels:
      app: syncplant-svc-controller
  template:
    metadata:
      labels:
        app: syncplant-svc-controller
    spec:
      serviceAccountName: syncplant-controller-sa
      containers:
        - name: controller
          image: bubua12/auto-config-controller:latest
          imagePullPolicy: IfNotPresent

⁠📄 许可证

MIT License - 查看 LICENSE⁠ 文件了解详情


Made with ❤️ by Kubernetes Developer

Tag summary

Content type

Image

Digest

sha256:6bc5ab2a7…

Size

21 MB

Last updated

7 months ago

docker pull bubua12/auto-config-controller:1.1.0