Merge pull request #6133 from jabellard/sidecar-containers
Add Support for API Server Sidecar Containers in Karmada Operator
This commit is contained in:
commit
729a8d6822
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -353,6 +353,12 @@ type KarmadaAPIServer struct {
|
||||||
// More info: https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/
|
// More info: https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/
|
||||||
// +optional
|
// +optional
|
||||||
FeatureGates map[string]bool `json:"featureGates,omitempty"`
|
FeatureGates map[string]bool `json:"featureGates,omitempty"`
|
||||||
|
|
||||||
|
// SidecarContainers specifies a list of sidecar containers to be deployed
|
||||||
|
// within the Karmada API server pod.
|
||||||
|
// This enables users to integrate auxiliary services such as KMS plugins for configuring encryption at rest.
|
||||||
|
// +optional
|
||||||
|
SidecarContainers []corev1.Container `json:"sidecarContainers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// KarmadaAggregatedAPIServer holds settings to karmada-aggregated-apiserver component of the karmada.
|
// KarmadaAggregatedAPIServer holds settings to karmada-aggregated-apiserver component of the karmada.
|
||||||
|
|
|
@ -341,6 +341,13 @@ func (in *KarmadaAPIServer) DeepCopyInto(out *KarmadaAPIServer) {
|
||||||
(*out)[key] = val
|
(*out)[key] = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.SidecarContainers != nil {
|
||||||
|
in, out := &in.SidecarContainers, &out.SidecarContainers
|
||||||
|
*out = make([]v1.Container, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ func installKarmadaAPIServer(client clientset.Interface, cfg *operatorv1alpha1.K
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithPriorityClassName(cfg.CommonSettings.PriorityClassName).
|
WithPriorityClassName(cfg.CommonSettings.PriorityClassName).
|
||||||
WithExtraArgs(cfg.ExtraArgs).WithExtraVolumeMounts(cfg.ExtraVolumeMounts).
|
WithExtraArgs(cfg.ExtraArgs).WithExtraVolumeMounts(cfg.ExtraVolumeMounts).
|
||||||
WithExtraVolumes(cfg.ExtraVolumes).WithResources(cfg.Resources).ForDeployment(apiserverDeployment)
|
WithExtraVolumes(cfg.ExtraVolumes).WithSidecarContainers(cfg.SidecarContainers).WithResources(cfg.Resources).ForDeployment(apiserverDeployment)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateDeployment(client, apiserverDeployment); err != nil {
|
if err := apiclient.CreateOrUpdateDeployment(client, apiserverDeployment); err != nil {
|
||||||
return fmt.Errorf("error when creating deployment for %s, err: %w", apiserverDeployment.Name, err)
|
return fmt.Errorf("error when creating deployment for %s, err: %w", apiserverDeployment.Name, err)
|
||||||
|
|
|
@ -41,6 +41,7 @@ type Patcher struct {
|
||||||
extraArgs map[string]string
|
extraArgs map[string]string
|
||||||
extraVolumes []corev1.Volume
|
extraVolumes []corev1.Volume
|
||||||
extraVolumeMounts []corev1.VolumeMount
|
extraVolumeMounts []corev1.VolumeMount
|
||||||
|
sidecarContainers []corev1.Container
|
||||||
featureGates map[string]bool
|
featureGates map[string]bool
|
||||||
volume *operatorv1alpha1.VolumeData
|
volume *operatorv1alpha1.VolumeData
|
||||||
resources corev1.ResourceRequirements
|
resources corev1.ResourceRequirements
|
||||||
|
@ -87,6 +88,12 @@ func (p *Patcher) WithExtraVolumeMounts(extraVolumeMounts []corev1.VolumeMount)
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithSidecarContainers sets sidecar containers for the patcher.
|
||||||
|
func (p *Patcher) WithSidecarContainers(sidecarContainers []corev1.Container) *Patcher {
|
||||||
|
p.sidecarContainers = sidecarContainers
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// WithFeatureGates sets featureGates to the patcher.
|
// WithFeatureGates sets featureGates to the patcher.
|
||||||
func (p *Patcher) WithFeatureGates(featureGates map[string]bool) *Patcher {
|
func (p *Patcher) WithFeatureGates(featureGates map[string]bool) *Patcher {
|
||||||
p.featureGates = featureGates
|
p.featureGates = featureGates
|
||||||
|
@ -144,6 +151,7 @@ func (p *Patcher) ForDeployment(deployment *appsv1.Deployment) {
|
||||||
command = append(command, buildArgumentListFromMap(argsMap, overrideArgs)...)
|
command = append(command, buildArgumentListFromMap(argsMap, overrideArgs)...)
|
||||||
deployment.Spec.Template.Spec.Containers[0].Command = command
|
deployment.Spec.Template.Spec.Containers[0].Command = command
|
||||||
}
|
}
|
||||||
|
deployment.Spec.Template.Spec.Containers = append(deployment.Spec.Template.Spec.Containers, p.sidecarContainers...)
|
||||||
// Add extra volumes and volume mounts
|
// Add extra volumes and volume mounts
|
||||||
// First container in the pod is expected to contain the Karmada component
|
// First container in the pod is expected to contain the Karmada component
|
||||||
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, p.extraVolumes...)
|
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, p.extraVolumes...)
|
||||||
|
|
Loading…
Reference in New Issue