enforce-ingress-class

command module
v0.0.0-...-0ba555b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 11 Imported by: 0

README

enforce-ingress-class

自动强制为 Ingress 指定一个 IngressClass

使用方式

# create serviceaccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: enforce-ingress-class
  namespace: autoops
---
# create clusterrole
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: enforce-ingress-class
rules:
  - apiGroups: [""]
    resources: ["namespaces"]
    verbs: ["get"]
---
# create clusterrolebinding
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: enforce-ingress-class
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: enforce-ingress-class
subjects:
  - kind: ServiceAccount
    name: enforce-ingress-class
    namespace: autoops
---
# create job
apiVersion: batch/v1
kind: Job
metadata:
  name: install-enforce-ingress-class
  namespace: autoops
spec:
  template:
    spec:
      serviceAccount: admission-bootstrapper
      containers:
        - name: admission-bootstrapper
          image: autoops/admission-bootstrapper
          env:
            - name: ADMISSION_NAME
              value: enforce-ingress-class
            - name: ADMISSION_IMAGE
              value: autoops/enforce-ingress-class
            - name: ADMISSION_ENVS
              value: ""
            - name: ADMISSION_SERVICE_ACCOUNT
              value: "enforce-ingress-class"
            - name: ADMISSION_MUTATING
              value: "true"
            - name: ADMISSION_IGNORE_FAILURE
              value: "false"
            - name: ADMISSION_SIDE_EFFECT
              value: "None"
            - name: ADMISSION_RULES
              value: '[{"operations":["CREATE"],"apiGroups":["extensions", "networking.k8s.io"], "apiVersions":["*"], "resources":["ingresses"]}]'
      restartPolicy: OnFailure
  • 为需要启用的命名空间,添加注解,指明要使用的内网

    autoops.enforce-ingress-class=nginx

    可以配合 enforce-ns-annotations 自动为新命名空间启用此注解

Credits

Guo Y.K., MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL