Skip to content

Commit

Permalink
operator: add extra annotations for karmada apiserver
Browse files Browse the repository at this point in the history
Signed-off-by: calvin <[email protected]>
  • Loading branch information
calvin committed Mar 5, 2024
1 parent b16f157 commit ad2a3b2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,12 @@ spec:
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
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:
description: ServiceSubnet is the subnet used by k8s services.
Defaults to "10.96.0.0/12".
Expand Down
6 changes: 6 additions & 0 deletions operator/config/crds/operator.karmada.io_karmadas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,12 @@ spec:
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
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:
description: ServiceSubnet is the subnet used by k8s services.
Defaults to "10.96.0.0/12".
Expand Down
5 changes: 5 additions & 0 deletions operator/pkg/apis/operator/v1alpha1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ type KarmadaAPIServer struct {
// +optional
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
// override. A key in this map is the flag name as it appears on the command line except
// without leading dash(es).
Expand Down
7 changes: 7 additions & 0 deletions operator/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions operator/pkg/controlplane/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
kuberuntime "k8s.io/apimachinery/pkg/runtime"
clientset "k8s.io/client-go/kubernetes"
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -100,6 +101,9 @@ func createKarmadaAPIServerService(client clientset.Interface, cfg *operatorv1al
return fmt.Errorf("error when decoding karmadaApiserver serive: %w", err)
}

// merge annotaions with configuration of karmada apiserver.
karmadaApiserverService.Annotations = labels.Merge(karmadaApiserverService.Labels, cfg.ServiceAnnotations)

if err := apiclient.CreateOrUpdateService(client, karmadaApiserverService); err != nil {
return fmt.Errorf("err when creating service for %s, err: %w", karmadaApiserverService.Name, err)
}
Expand Down

0 comments on commit ad2a3b2

Please sign in to comment.