operator: add extra annotations for service of karmada apiserver
Signed-off-by: calvin <wen.chen@daocloud.io>
This commit is contained in:
parent
b16f157bea
commit
739c4fada3
|
@ -642,6 +642,12 @@ spec:
|
||||||
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
|
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
serviceAnnotations:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
description: 'ServiceAnnotations is an extra set of annotations
|
||||||
|
for service of karmada apiserver. more info: https://github.com/karmada-io/karmada/issues/4634'
|
||||||
|
type: object
|
||||||
serviceSubnet:
|
serviceSubnet:
|
||||||
description: ServiceSubnet is the subnet used by k8s services.
|
description: ServiceSubnet is the subnet used by k8s services.
|
||||||
Defaults to "10.96.0.0/12".
|
Defaults to "10.96.0.0/12".
|
||||||
|
|
|
@ -642,6 +642,12 @@ spec:
|
||||||
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
|
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
serviceAnnotations:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
description: 'ServiceAnnotations is an extra set of annotations
|
||||||
|
for service of karmada apiserver. more info: https://github.com/karmada-io/karmada/issues/4634'
|
||||||
|
type: object
|
||||||
serviceSubnet:
|
serviceSubnet:
|
||||||
description: ServiceSubnet is the subnet used by k8s services.
|
description: ServiceSubnet is the subnet used by k8s services.
|
||||||
Defaults to "10.96.0.0/12".
|
Defaults to "10.96.0.0/12".
|
||||||
|
|
|
@ -228,6 +228,11 @@ type KarmadaAPIServer struct {
|
||||||
// +optional
|
// +optional
|
||||||
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
|
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
|
||||||
|
|
||||||
|
// ServiceAnnotations is an extra set of annotations for service of karmada apiserver.
|
||||||
|
// more info: https://github.com/karmada-io/karmada/issues/4634
|
||||||
|
// +optional
|
||||||
|
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"`
|
||||||
|
|
||||||
// ExtraArgs is an extra set of flags to pass to the kube-apiserver component or
|
// ExtraArgs is an extra set of flags to pass to the kube-apiserver component or
|
||||||
// override. A key in this map is the flag name as it appears on the command line except
|
// override. A key in this map is the flag name as it appears on the command line except
|
||||||
// without leading dash(es).
|
// without leading dash(es).
|
||||||
|
|
|
@ -221,6 +221,13 @@ func (in *KarmadaAPIServer) DeepCopyInto(out *KarmadaAPIServer) {
|
||||||
*out = new(string)
|
*out = new(string)
|
||||||
**out = **in
|
**out = **in
|
||||||
}
|
}
|
||||||
|
if in.ServiceAnnotations != nil {
|
||||||
|
in, out := &in.ServiceAnnotations, &out.ServiceAnnotations
|
||||||
|
*out = make(map[string]string, len(*in))
|
||||||
|
for key, val := range *in {
|
||||||
|
(*out)[key] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
if in.ExtraArgs != nil {
|
if in.ExtraArgs != nil {
|
||||||
in, out := &in.ExtraArgs, &out.ExtraArgs
|
in, out := &in.ExtraArgs, &out.ExtraArgs
|
||||||
*out = make(map[string]string, len(*in))
|
*out = make(map[string]string, len(*in))
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
|
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
kuberuntime "k8s.io/apimachinery/pkg/runtime"
|
kuberuntime "k8s.io/apimachinery/pkg/runtime"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
|
@ -100,6 +101,9 @@ func createKarmadaAPIServerService(client clientset.Interface, cfg *operatorv1al
|
||||||
return fmt.Errorf("error when decoding karmadaApiserver serive: %w", err)
|
return fmt.Errorf("error when decoding karmadaApiserver serive: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// merge annotaions with configuration of karmada apiserver.
|
||||||
|
karmadaApiserverService.Annotations = labels.Merge(karmadaApiserverService.Annotations, cfg.ServiceAnnotations)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateService(client, karmadaApiserverService); err != nil {
|
if err := apiclient.CreateOrUpdateService(client, karmadaApiserverService); err != nil {
|
||||||
return fmt.Errorf("err when creating service for %s, err: %w", karmadaApiserverService.Name, err)
|
return fmt.Errorf("err when creating service for %s, err: %w", karmadaApiserverService.Name, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue