diff --git a/charts/yurt-app-manager/.helmignore b/charts/yurt-app-manager/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/yurt-app-manager/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/yurt-app-manager/Chart.yaml b/charts/yurt-app-manager/Chart.yaml new file mode 100644 index 0000000..a98a85a --- /dev/null +++ b/charts/yurt-app-manager/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: yurt-app-manager +description: The controller manager that contains the nodepool controller and uniteddeployment controller. + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/yurt-app-manager/crds/apps.openyurt.io_nodepools.yaml b/charts/yurt-app-manager/crds/apps.openyurt.io_nodepools.yaml new file mode 100644 index 0000000..0d4ad6f --- /dev/null +++ b/charts/yurt-app-manager/crds/apps.openyurt.io_nodepools.yaml @@ -0,0 +1,173 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.7.0 + creationTimestamp: null + name: nodepools.apps.openyurt.io +spec: + group: apps.openyurt.io + names: + categories: + - all + kind: NodePool + listKind: NodePoolList + plural: nodepools + shortNames: + - np + singular: nodepool + scope: Cluster + versions: + - additionalPrinterColumns: + - description: The type of nodepool + jsonPath: .spec.type + name: Type + type: string + - description: The number of ready nodes in the pool + jsonPath: .status.readyNodeNum + name: ReadyNodes + type: integer + - jsonPath: .status.unreadyNodeNum + name: NotReadyNodes + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: NodePool is the Schema for the nodepools API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: NodePoolSpec defines the desired state of NodePool + properties: + annotations: + additionalProperties: + type: string + description: 'If specified, the Annotations will be added to all nodes. + NOTE: existing labels with samy keys on the nodes will be overwritten.' + type: object + labels: + additionalProperties: + type: string + description: 'If specified, the Labels will be added to all nodes. + NOTE: existing labels with samy keys on the nodes will be overwritten.' + type: object + selector: + description: A label query over nodes to consider for adding to the + pool + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of string values. If the + operator is In or NotIn, the values array must be non-empty. + If the operator is Exists or DoesNotExist, the values + array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single + {key,value} in the matchLabels map is equivalent to an element + of matchExpressions, whose key field is "key", the operator + is "In", and the values array contains only "value". The requirements + are ANDed. + type: object + type: object + taints: + description: If specified, the Taints will be added to all nodes. + items: + description: The node this Taint is attached to has the "effect" + on any pod that does not tolerate the Taint. + properties: + effect: + description: Required. The effect of the taint on pods that + do not tolerate the taint. Valid effects are NoSchedule, PreferNoSchedule + and NoExecute. + type: string + key: + description: Required. The taint key to be applied to a node. + type: string + timeAdded: + description: TimeAdded represents the time at which the taint + was added. It is only written for NoExecute taints. + format: date-time + type: string + value: + description: The taint value corresponding to the taint key. + type: string + required: + - effect + - key + type: object + type: array + type: + description: The type of the NodePool + type: string + type: object + status: + description: NodePoolStatus defines the observed state of NodePool + properties: + nodes: + description: The list of nodes' names in the pool + items: + type: string + type: array + readyNodeNum: + description: Total number of ready nodes in the pool. + format: int32 + type: integer + unreadyNodeNum: + description: Total number of unready nodes in the pool. + format: int32 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/charts/yurt-app-manager/crds/apps.openyurt.io_uniteddeployments.yaml b/charts/yurt-app-manager/crds/apps.openyurt.io_uniteddeployments.yaml new file mode 100644 index 0000000..83446b5 --- /dev/null +++ b/charts/yurt-app-manager/crds/apps.openyurt.io_uniteddeployments.yaml @@ -0,0 +1,367 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.7.0 + creationTimestamp: null + name: uniteddeployments.apps.openyurt.io +spec: + group: apps.openyurt.io + names: + kind: UnitedDeployment + listKind: UnitedDeploymentList + plural: uniteddeployments + shortNames: + - ud + singular: uniteddeployment + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: The number of pods ready. + jsonPath: .status.readyReplicas + name: READY + type: integer + - description: The WorkloadTemplate Type. + jsonPath: .status.templateType + name: WorkloadTemplate + type: string + - description: CreationTimestamp is a timestamp representing the server time when + this object was created. It is not guaranteed to be set in happens-before + order across separate operations. Clients may not set this value. It is represented + in RFC3339 form and is in UTC. + jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: UnitedDeployment is the Schema for the uniteddeployments API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: UnitedDeploymentSpec defines the desired state of UnitedDeployment. + properties: + revisionHistoryLimit: + description: Indicates the number of histories to be conserved. If + unspecified, defaults to 10. + format: int32 + type: integer + selector: + description: Selector is a label query over pods that should match + the replica count. It must match the pod template's labels. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of string values. If the + operator is In or NotIn, the values array must be non-empty. + If the operator is Exists or DoesNotExist, the values + array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single + {key,value} in the matchLabels map is equivalent to an element + of matchExpressions, whose key field is "key", the operator + is "In", and the values array contains only "value". The requirements + are ANDed. + type: object + type: object + topology: + description: Topology describes the pods distribution detail between + each of pools. + properties: + pools: + description: Contains the details of each pool. Each element in + this array represents one pool which will be provisioned and + managed by UnitedDeployment. + items: + description: Pool defines the detail of a pool. + properties: + name: + description: Indicates pool name as a DNS_LABEL, which will + be used to generate pool workload name prefix in the format + '--'. Name should be unique + between all of the pools under one UnitedDeployment. Name + is NodePool Name + type: string + nodeSelectorTerm: + description: Indicates the node selector to form the pool. + Depending on the node selector, pods provisioned could + be distributed across multiple groups of nodes. A pool's + nodeSelectorTerm is not allowed to be updated. + properties: + matchExpressions: + description: A list of node selector requirements by + node's labels. + items: + description: A node selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: The label key that the selector applies + to. + type: string + operator: + description: Represents a key's relationship to + a set of values. Valid operators are In, NotIn, + Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: An array of string values. If the + operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. If the operator + is Gt or Lt, the values array must have a single + element, which will be interpreted as an integer. + This array is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements by + node's fields. + items: + description: A node selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: The label key that the selector applies + to. + type: string + operator: + description: Represents a key's relationship to + a set of values. Valid operators are In, NotIn, + Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: An array of string values. If the + operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. If the operator + is Gt or Lt, the values array must have a single + element, which will be interpreted as an integer. + This array is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + patch: + description: Indicates the patch for the templateSpec Now + support strategic merge path :https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#notes-on-the-strategic-merge-patch + Patch takes precedence over Replicas fields If the Patch + also modifies the Replicas, use the Replicas value in + the Patch + type: object + replicas: + description: Indicates the number of the pod to be created + under this pool. + format: int32 + type: integer + tolerations: + description: Indicates the tolerations the pods under this + pool have. A pool's tolerations is not allowed to be updated. + items: + description: The pod this Toleration is attached to tolerates + any taint that matches the triple + using the matching operator . + properties: + effect: + description: Effect indicates the taint effect to + match. Empty means match all taint effects. When + specified, allowed values are NoSchedule, PreferNoSchedule + and NoExecute. + type: string + key: + description: Key is the taint key that the toleration + applies to. Empty means match all taint keys. If + the key is empty, operator must be Exists; this + combination means to match all values and all keys. + type: string + operator: + description: Operator represents a key's relationship + to the value. Valid operators are Exists and Equal. + Defaults to Equal. Exists is equivalent to wildcard + for value, so that a pod can tolerate all taints + of a particular category. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period + of time the toleration (which must be of effect + NoExecute, otherwise this field is ignored) tolerates + the taint. By default, it is not set, which means + tolerate the taint forever (do not evict). Zero + and negative values will be treated as 0 (evict + immediately) by the system. + format: int64 + type: integer + value: + description: Value is the taint value the toleration + matches to. If the operator is Exists, the value + should be empty, otherwise just a regular string. + type: string + type: object + type: array + required: + - name + type: object + type: array + type: object + workloadTemplate: + description: WorkloadTemplate describes the pool that will be created. + properties: + deploymentTemplate: + description: Deployment template + properties: + metadata: + x-kubernetes-preserve-unknown-fields: true + spec: + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + statefulSetTemplate: + description: StatefulSet template + properties: + metadata: + x-kubernetes-preserve-unknown-fields: true + spec: + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + type: object + required: + - selector + type: object + status: + description: UnitedDeploymentStatus defines the observed state of UnitedDeployment. + properties: + collisionCount: + description: Count of hash collisions for the UnitedDeployment. The + UnitedDeployment controller uses this field as a collision avoidance + mechanism when it needs to create the name for the newest ControllerRevision. + format: int32 + type: integer + conditions: + description: Represents the latest available observations of a UnitedDeployment's + current state. + items: + description: UnitedDeploymentCondition describes current state of + a UnitedDeployment. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of in place set condition. + type: string + type: object + type: array + currentRevision: + description: CurrentRevision, if not empty, indicates the current + version of the UnitedDeployment. + type: string + observedGeneration: + description: ObservedGeneration is the most recent generation observed + for this UnitedDeployment. It corresponds to the UnitedDeployment's + generation, which is updated on mutation by the API Server. + format: int64 + type: integer + poolReplicas: + additionalProperties: + format: int32 + type: integer + description: Records the topology detail information of the replicas + of each pool. + type: object + readyReplicas: + description: The number of ready replicas. + format: int32 + type: integer + replicas: + description: Replicas is the most recently observed number of replicas. + format: int32 + type: integer + templateType: + description: TemplateType indicates the type of PoolTemplate + type: string + required: + - currentRevision + - replicas + - templateType + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/charts/yurt-app-manager/crds/apps.openyurt.io_yurtappdaemons.yaml b/charts/yurt-app-manager/crds/apps.openyurt.io_yurtappdaemons.yaml new file mode 100644 index 0000000..c851193 --- /dev/null +++ b/charts/yurt-app-manager/crds/apps.openyurt.io_yurtappdaemons.yaml @@ -0,0 +1,245 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.7.0 + creationTimestamp: null + name: yurtappdaemons.apps.openyurt.io +spec: + group: apps.openyurt.io + names: + kind: YurtAppDaemon + listKind: YurtAppDaemonList + plural: yurtappdaemons + shortNames: + - yad + singular: yurtappdaemon + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: The WorkloadTemplate Type. + jsonPath: .status.templateType + name: WorkloadTemplate + type: string + - description: CreationTimestamp is a timestamp representing the server time when + this object was created. It is not guaranteed to be set in happens-before + order across separate operations. Clients may not set this value. It is represented + in RFC3339 form and is in UTC. + jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: YurtAppDaemon is the Schema for the YurtAppDaemon API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: YurtAppDaemonSpec defines the desired state of YurtAppDaemon. + properties: + nodepoolSelector: + description: NodePoolSelector is a label query over nodepool that + should match the replica count. It must match the nodepool's labels. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of string values. If the + operator is In or NotIn, the values array must be non-empty. + If the operator is Exists or DoesNotExist, the values + array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single + {key,value} in the matchLabels map is equivalent to an element + of matchExpressions, whose key field is "key", the operator + is "In", and the values array contains only "value". The requirements + are ANDed. + type: object + type: object + revisionHistoryLimit: + description: Indicates the number of histories to be conserved. If + unspecified, defaults to 10. + format: int32 + type: integer + selector: + description: Selector is a label query over pods that should match + the replica count. It must match the pod template's labels. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of string values. If the + operator is In or NotIn, the values array must be non-empty. + If the operator is Exists or DoesNotExist, the values + array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single + {key,value} in the matchLabels map is equivalent to an element + of matchExpressions, whose key field is "key", the operator + is "In", and the values array contains only "value". The requirements + are ANDed. + type: object + type: object + workloadTemplate: + description: WorkloadTemplate describes the pool that will be created. + properties: + deploymentTemplate: + description: Deployment template + properties: + metadata: + x-kubernetes-preserve-unknown-fields: true + spec: + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + statefulSetTemplate: + description: StatefulSet template + properties: + metadata: + x-kubernetes-preserve-unknown-fields: true + spec: + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + type: object + required: + - nodepoolSelector + - selector + type: object + status: + description: YurtAppDaemonStatus defines the observed state of YurtAppDaemon. + properties: + collisionCount: + description: Count of hash collisions for the YurtAppDaemon. The YurtAppDaemon + controller uses this field as a collision avoidance mechanism when + it needs to create the name for the newest ControllerRevision. + format: int32 + type: integer + conditions: + description: Represents the latest available observations of a YurtAppDaemon's + current state. + items: + description: YurtAppDaemonCondition describes current state of a + YurtAppDaemon. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of in place set condition. + type: string + type: object + type: array + currentRevision: + description: CurrentRevision, if not empty, indicates the current + version of the YurtAppDaemon. + type: string + nodepools: + description: NodePools indicates the list of node pools selected by + YurtAppDaemon + items: + type: string + type: array + observedGeneration: + description: ObservedGeneration is the most recent generation observed + for this YurtAppDaemon. It corresponds to the YurtAppDaemon's generation, + which is updated on mutation by the API Server. + format: int64 + type: integer + templateType: + description: TemplateType indicates the type of PoolTemplate + type: string + required: + - currentRevision + - templateType + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/charts/yurt-app-manager/crds/apps.openyurt.io_yurtingresses.yaml b/charts/yurt-app-manager/crds/apps.openyurt.io_yurtingresses.yaml new file mode 100644 index 0000000..6ae0fe8 --- /dev/null +++ b/charts/yurt-app-manager/crds/apps.openyurt.io_yurtingresses.yaml @@ -0,0 +1,191 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.7.0 + creationTimestamp: null + name: yurtingresses.apps.openyurt.io +spec: + group: apps.openyurt.io + names: + categories: + - all + kind: YurtIngress + listKind: YurtIngressList + plural: yurtingresses + shortNames: + - ying + singular: yurtingress + scope: Cluster + versions: + - additionalPrinterColumns: + - description: The nginx ingress controller replicas per pool + jsonPath: .status.ingress_controller_replicas_per_pool + name: Replicas-Per-Pool + type: integer + - description: The number of pools on which ingress is enabled + jsonPath: .status.readyNum + name: ReadyNum + type: integer + - description: The number of pools on which ingress is enabling or enable failed + jsonPath: .status.unreadyNum + name: NotReadyNum + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: YurtIngress is the Schema for the yurtingresses API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: YurtIngressSpec defines the desired state of YurtIngress + properties: + ingress_controller_image: + description: Indicates the ingress controller image url. + type: string + ingress_controller_replicas_per_pool: + description: Indicates the number of the ingress controllers to be + deployed under all the specified nodepools. + format: int32 + type: integer + ingress_webhook_certgen_image: + description: Indicates the ingress webhook image url. + type: string + pools: + description: Indicates all the nodepools on which to enable ingress. + items: + description: IngressPool defines the details of a Pool for ingress + properties: + ingress_ips: + description: IngressIPs is a list of IP addresses for which + nodes will also accept traffic for this service. + items: + type: string + type: array + name: + description: Indicates the pool name. + type: string + required: + - name + type: object + type: array + type: object + status: + description: YurtIngressStatus defines the observed state of YurtIngress + properties: + conditions: + description: Indicates all the nodepools on which to enable ingress. + properties: + ingressreadypools: + description: Indicates the pools that ingress controller is deployed + successfully. + items: + description: IngressPool defines the details of a Pool for ingress + properties: + ingress_ips: + description: IngressIPs is a list of IP addresses for which + nodes will also accept traffic for this service. + items: + type: string + type: array + name: + description: Indicates the pool name. + type: string + required: + - name + type: object + type: array + ingressunreadypools: + description: Indicates the pools that ingress controller is being + deployed or deployed failed. + items: + description: IngressNotReadyPool defines the condition details + of an ingress not ready Pool + properties: + pool: + description: Indicates the base pool info. + properties: + ingress_ips: + description: IngressIPs is a list of IP addresses for + which nodes will also accept traffic for this service. + items: + type: string + type: array + name: + description: Indicates the pool name. + type: string + required: + - name + type: object + unreadyinfo: + description: Info of ingress not ready condition. + properties: + lastTransitionTime: + description: Last time the condition transitioned from + one status to another. + format: date-time + type: string + message: + description: A human readable message indicating details + about the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + type: + description: Type of ingress not ready condition. + type: string + type: object + required: + - pool + type: object + type: array + type: object + ingress_controller_image: + description: Indicates the ingress controller image url. + type: string + ingress_controller_replicas_per_pool: + description: Indicates the number of the ingress controllers deployed + under all the specified nodepools. + format: int32 + type: integer + ingress_webhook_certgen_image: + description: Indicates the ingress webhook image url. + type: string + readyNum: + description: Total number of ready pools on which ingress is enabled. + format: int32 + type: integer + unreadyNum: + description: Total number of unready pools on which ingress is enabling + or enable failed. + format: int32 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/charts/yurt-app-manager/templates/NOTES.txt b/charts/yurt-app-manager/templates/NOTES.txt new file mode 100644 index 0000000..96a549a --- /dev/null +++ b/charts/yurt-app-manager/templates/NOTES.txt @@ -0,0 +1,6 @@ +This application contains 4 CRD/controllers: NodePool, UnitedDeployment, YurtAppDaemon and YurtIngress. + +The NodePool provides a convenient management experience for a pool of nodes within the same region or site. +The UnitedDeployment defines a new edge application management methodology of using per node pool workload. +The YurtAppDaemon provides a similar K8S DaemonSet support for user app workload from the NodePool level. +The YurtIngress is responsible to deploy configurable ingress controller to the user specified NodePools. \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/_helpers.tpl b/charts/yurt-app-manager/templates/_helpers.tpl new file mode 100644 index 0000000..50028e0 --- /dev/null +++ b/charts/yurt-app-manager/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "yurt-app-manager.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "yurt-app-manager.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "yurt-app-manager.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "yurt-app-manager.labels" -}} +helm.sh/chart: {{ include "yurt-app-manager.chart" . }} +{{ include "yurt-app-manager.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "yurt-app-manager.selectorLabels" -}} +app.kubernetes.io/name: {{ include "yurt-app-manager.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "yurt-app-manager.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "yurt-app-manager.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/yurt-app-manager/templates/clusterrole.yaml b/charts/yurt-app-manager/templates/clusterrole.yaml new file mode 100644 index 0000000..a72ee50 --- /dev/null +++ b/charts/yurt-app-manager/templates/clusterrole.yaml @@ -0,0 +1,315 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "yurt-app-manager.serviceAccountName" . }} +rules: + - apiGroups: + - admissionregistration.k8s.io + resources: + - mutatingwebhookconfigurations + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - admissionregistration.k8s.io + resources: + - validatingwebhookconfigurations + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps + resources: + - controllerrevisions + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps + resources: + - deployments + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps + resources: + - deployments/status + verbs: + - get + - patch + - update + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps + resources: + - statefulsets/status + verbs: + - get + - patch + - update + - apiGroups: + - apps.openyurt.io + resources: + - nodepools + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps.openyurt.io + resources: + - nodepools/status + verbs: + - get + - patch + - update + - apiGroups: + - apps.openyurt.io + resources: + - uniteddeployments + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps.openyurt.io + resources: + - uniteddeployments/status + verbs: + - get + - patch + - update + - apiGroups: + - apps.openyurt.io + resources: + - yurtappdaemons + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps.openyurt.io + resources: + - yurtappdaemons/status + verbs: + - get + - patch + - update + - apiGroups: + - apps.openyurt.io + resources: + - yurtingresses + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps.openyurt.io + resources: + - yurtingresses/status + verbs: + - get + - patch + - update + - apiGroups: + - batch + resources: + - jobs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - configmaps + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - namespaces + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - nodes + verbs: + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - pods + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - secrets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - serviceaccounts + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - services + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - rbac.authorization.k8s.io + resources: + - clusterrolebindings + verbs: + - '*' + - apiGroups: + - rbac.authorization.k8s.io + resources: + - clusterroles + verbs: + - '*' + - apiGroups: + - rbac.authorization.k8s.io + resources: + - rolebindings + verbs: + - '*' + - apiGroups: + - rbac.authorization.k8s.io + resources: + - roles + verbs: + - '*' \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/clusterrolebinding.yaml b/charts/yurt-app-manager/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..e9fc210 --- /dev/null +++ b/charts/yurt-app-manager/templates/clusterrolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "yurt-app-manager.serviceAccountName" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "yurt-app-manager.serviceAccountName" . }} +subjects: + - kind: ServiceAccount + name: {{ include "yurt-app-manager.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/deployment.yaml b/charts/yurt-app-manager/templates/deployment.yaml new file mode 100644 index 0000000..fd48810 --- /dev/null +++ b/charts/yurt-app-manager/templates/deployment.yaml @@ -0,0 +1,99 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "yurt-app-manager.fullname" . }} + labels: + {{- include "yurt-app-manager.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "yurt-app-manager.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "yurt-app-manager.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "yurt-app-manager.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --enable-leader-election + - --v=4 + ports: + - name: webhook-server + containerPort: {{ .Values.webhook.port }} + protocol: TCP + - name: health + containerPort: 8000 + protocol: TCP + env: + - name: WEBHOOK_PORT + value: {{ .Values.webhook.port | quote }} + - name: SECRET_NAME + value: {{ include "yurt-app-manager.fullname" . | quote }} + - name: SERVICE_NAME + value: {{ include "yurt-app-manager.fullname" . | quote }} + - name: MUTATING_WEBHOOK_CONFIGURATION_NAME + value: {{ include "yurt-app-manager.fullname" . | quote }} + - name: VALIDATING_WEBHOOK_CONFIGURATION_NAME + value: {{ include "yurt-app-manager.fullname" . | quote }} + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: WEBHOOK_CERT_DIR + value: {{ .Values.webhook.certDir | quote }} + livenessProbe: + httpGet: + path: /healthz + port: webhook-server + scheme: HTTPS + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /readyz + port: health + initialDelaySeconds: 5 + periodSeconds: 10 + volumeMounts: + - mountPath: {{ .Values.webhook.certDir }} + name: cert + readOnly: true + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.priorityClassName }} + priorityClassName: {{ . }} + {{- end }} + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: {{ include "yurt-app-manager.fullname" . }} diff --git a/charts/yurt-app-manager/templates/mutatingwebhookconfiguration.yaml b/charts/yurt-app-manager/templates/mutatingwebhookconfiguration.yaml new file mode 100644 index 0000000..1f7403f --- /dev/null +++ b/charts/yurt-app-manager/templates/mutatingwebhookconfiguration.yaml @@ -0,0 +1,71 @@ +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + name: {{ include "yurt-app-manager.fullname" . }} +webhooks: +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /mutate-apps-openyurt-io-v1alpha1-nodepool + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: mnodepool.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - nodepools +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /mutate-apps-openyurt-io-v1alpha1-uniteddeployment + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: muniteddeployment.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - uniteddeployments +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /mutate-apps-openyurt-io-v1alpha1-yurtappdaemon + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: myurtappdaemon.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - yurtappdaemons \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/role.yaml b/charts/yurt-app-manager/templates/role.yaml new file mode 100644 index 0000000..95616fa --- /dev/null +++ b/charts/yurt-app-manager/templates/role.yaml @@ -0,0 +1,31 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "yurt-app-manager.serviceAccountName" . }} +rules: + - apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete + - apiGroups: + - "" + resources: + - configmaps/status + verbs: + - get + - update + - patch + - apiGroups: + - "" + resources: + - events + verbs: + - create \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/rolebinding.yaml b/charts/yurt-app-manager/templates/rolebinding.yaml new file mode 100644 index 0000000..4a31c54 --- /dev/null +++ b/charts/yurt-app-manager/templates/rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "yurt-app-manager.serviceAccountName" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "yurt-app-manager.serviceAccountName" . }} +subjects: + - kind: ServiceAccount + name: {{ include "yurt-app-manager.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/secret.yaml b/charts/yurt-app-manager/templates/secret.yaml new file mode 100644 index 0000000..9025a61 --- /dev/null +++ b/charts/yurt-app-manager/templates/secret.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "yurt-app-manager.fullname" . }} \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/service.yaml b/charts/yurt-app-manager/templates/service.yaml new file mode 100644 index 0000000..7d05552 --- /dev/null +++ b/charts/yurt-app-manager/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "yurt-app-manager.fullname" . }} +spec: + {{- with .Values.service.type }} + type: {{ . }} + {{- end }} + ports: + - name: webhook-server + port: {{ .Values.service.port }} + protocol: TCP + targetPort: webhook-server + selector: + {{- include "yurt-app-manager.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/charts/yurt-app-manager/templates/serviceaccount.yaml b/charts/yurt-app-manager/templates/serviceaccount.yaml new file mode 100644 index 0000000..1a4fd1c --- /dev/null +++ b/charts/yurt-app-manager/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "yurt-app-manager.serviceAccountName" . }} + labels: + {{- include "yurt-app-manager.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/yurt-app-manager/templates/validatingwebhookconfiguration.yaml b/charts/yurt-app-manager/templates/validatingwebhookconfiguration.yaml new file mode 100644 index 0000000..396b931 --- /dev/null +++ b/charts/yurt-app-manager/templates/validatingwebhookconfiguration.yaml @@ -0,0 +1,95 @@ +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: {{ include "yurt-app-manager.fullname" . }} +webhooks: +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /validate-apps-openyurt-io-v1alpha1-nodepool + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: vnodepool.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + - DELETE + resources: + - nodepools +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /validate-apps-openyurt-io-v1alpha1-uniteddeployment + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: vuniteddeployment.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - uniteddeployments +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /validate-apps-openyurt-io-v1alpha1-yurtappdaemon + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: vyurtappdaemon.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - yurtappdaemons +- clientConfig: + caBundle: Cg== + service: + name: {{ include "yurt-app-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + port: {{ .Values.service.port }} + path: /validate-apps-openyurt-io-v1alpha1-yurtingress + admissionReviewVersions: + - v1 + sideEffects: None + failurePolicy: Fail + name: vyurtingress.kb.io + rules: + - apiGroups: + - apps.openyurt.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + - DELETE + resources: + - yurtingresses \ No newline at end of file diff --git a/charts/yurt-app-manager/values.yaml b/charts/yurt-app-manager/values.yaml new file mode 100644 index 0000000..926ebdb --- /dev/null +++ b/charts/yurt-app-manager/values.yaml @@ -0,0 +1,65 @@ +# Default values for yurt-app-manager. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: openyurt/yurt-app-manager + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 443 + +webhook: + port: 9876 + certDir: /tmp/k8s-webhook-server/serving-certs + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +priorityClassName: system-node-critical \ No newline at end of file diff --git a/pkg/yurtappmanager/webhook/util/configuration/configuration.go b/pkg/yurtappmanager/webhook/util/configuration/configuration.go index 936de5e..32125f7 100644 --- a/pkg/yurtappmanager/webhook/util/configuration/configuration.go +++ b/pkg/yurtappmanager/webhook/util/configuration/configuration.go @@ -23,6 +23,7 @@ import ( "fmt" "net/url" + "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/util" webhookutil "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/util" adminssionv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/types" @@ -30,12 +31,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -const ( - mutatingWebhookConfigurationName = "yurt-app-mutating-webhook-configuration" - validatingWebhookConfigurationName = "yurt-app-validating-webhook-configuration" -) - func Ensure(c client.Client, handlers map[string]webhookutil.Handler, caBundle []byte) error { + mutatingWebhookConfigurationName := util.GetMutatingWebhookConfigurationName() + validatingWebhookConfigurationName := util.GetValidatingWebhookConfigurationName() + mutatingConfig := &adminssionv1.MutatingWebhookConfiguration{} if err := c.Get(context.TODO(), types.NamespacedName{Name: mutatingWebhookConfigurationName}, mutatingConfig); err != nil { return fmt.Errorf("not found MutatingWebhookConfiguration %s", mutatingWebhookConfigurationName) diff --git a/pkg/yurtappmanager/webhook/util/util.go b/pkg/yurtappmanager/webhook/util/util.go index 8564b60..9390683 100644 --- a/pkg/yurtappmanager/webhook/util/util.go +++ b/pkg/yurtappmanager/webhook/util/util.go @@ -67,3 +67,17 @@ func GetCertDir() string { } return "/tmp/yurt-app-webhook-certs" } + +func GetMutatingWebhookConfigurationName() string { + if p := os.Getenv("MUTATING_WEBHOOK_CONFIGURATION_NAME"); len(p) > 0 { + return p + } + return "yurt-app-mutating-webhook-configuration" +} + +func GetValidatingWebhookConfigurationName() string { + if p := os.Getenv("VALIDATING_WEBHOOK_CONFIGURATION_NAME"); len(p) > 0 { + return p + } + return "yurt-app-validating-webhook-configuration" +}