-
Notifications
You must be signed in to change notification settings - Fork 901
Feature cms api operator #2463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
a932846905
wants to merge
18
commits into
openkruise:master
Choose a base branch
from
a932846905:feature-cms-api-operator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature cms api operator #2463
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8e2052f
define configmapset crd
b7b9bda
add configmapset operator
f15fff2
adjust code style
fc4d872
adjust code style
d03ad95
fix may panic problem
4b2d757
set cms data is required
e9ad703
adjust cms maxUnavailable bigger than zero
f167f77
adjust cms crr name suffix
7125421
adjust cms.Spec.Selector validate
9744ef6
adjust cms ReloadSidecar default name
b6568ed
adjust cms conversion integer logic
512e744
adjust cms reload-sidecar readiness check path
3402468
fix cms controller bug
04a9e98
fix cms controller bug
634ff33
fix cms controller bug
556e518
fix cms controller bug
e1886db
fix cms controller bug
e894dd0
fix cms api default value
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| /* | ||
| Copyright 2024 The Kruise Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/util/intstr" | ||
| ) | ||
|
|
||
| // ConfigMapSetSpec defines the desired state of ConfigMapSet | ||
| type ConfigMapSetSpec struct { | ||
| // CustomVersion alias for the current update revision | ||
| // +optional | ||
| CustomVersion string `json:"customVersion,omitempty"` | ||
|
|
||
| // Selector is a label query over pods that should be updated | ||
| // +optional | ||
| Selector *metav1.LabelSelector `json:"selector,omitempty"` | ||
|
|
||
| // Data contains the configuration data to be updated | ||
| // +optional | ||
| Data map[string]string `json:"data,omitempty"` | ||
|
|
||
| // Containers defines the business containers that need to be updated | ||
| // +optional | ||
| Containers []ConfigMapSetContainer `json:"containers,omitempty"` | ||
|
|
||
| // ReloadSidecarConfig defines the container injected during Pod creation to update configuration files | ||
| // +optional | ||
| ReloadSidecarConfig *ReloadSidecarConfig `json:"reloadSidecarConfig,omitempty"` | ||
|
|
||
| // EffectPolicy defines how the configuration update takes effect | ||
| // +optional | ||
| EffectPolicy *EffectPolicy `json:"effectPolicy,omitempty"` | ||
|
|
||
| // RevisionHistoryLimit indicates the maximum quantity of stored revisions about the ConfigMapSet | ||
| // +optional | ||
| RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty"` | ||
|
|
||
| // UpdateStrategy indicates the strategy that the ConfigMapSet controller will use to perform updates | ||
| // +optional | ||
| UpdateStrategy *ConfigMapSetUpdateStrategy `json:"updateStrategy,omitempty"` | ||
| } | ||
|
|
||
| type ConfigMapSetContainer struct { | ||
| Name string `json:"name,omitempty"` | ||
| NameFrom *SourceContainerNameSource `json:"nameFrom,omitempty"` | ||
| MountPath string `json:"mountPath,omitempty"` | ||
| } | ||
|
|
||
| type ReloadSidecarConfig struct { | ||
| // Type of the reload sidecar config (k8s, sidecarset, custom) | ||
| Type ReloadSidecarType `json:"type,omitempty"` | ||
| // Config provides the configuration for the chosen type | ||
| Config *ReloadSidecarConfigData `json:"config,omitempty"` | ||
| } | ||
|
|
||
| type ReloadSidecarType string | ||
|
|
||
| const ( | ||
| ReloadSidecarTypeK8s ReloadSidecarType = "k8s" | ||
| ReloadSidecarTypeSidecarSet ReloadSidecarType = "sidecarset" | ||
| ReloadSidecarTypeCustom ReloadSidecarType = "custom" | ||
| ) | ||
|
|
||
| type ReloadSidecarConfigData struct { | ||
| // Name for k8s type | ||
| Name string `json:"name,omitempty"` | ||
| // Image for k8s type | ||
| Image string `json:"image,omitempty"` | ||
| // RestartPolicy for k8s type | ||
| RestartPolicy corev1.ContainerRestartPolicy `json:"restartPolicy,omitempty"` | ||
| // Command for k8s type | ||
| Command []string `json:"command,omitempty"` | ||
|
|
||
| // SidecarSetRef for sidecarset type | ||
| SidecarSetRef *SidecarSetRef `json:"sidecarSetRef,omitempty"` | ||
|
|
||
| // ConfigMapRef for custom type | ||
| ConfigMapRef *ConfigMapRef `json:"configMapRef,omitempty"` | ||
| } | ||
|
|
||
| type SidecarSetRef struct { | ||
| Name string `json:"name,omitempty"` | ||
| ContainerName string `json:"containerName,omitempty"` | ||
| } | ||
|
|
||
| type ConfigMapRef struct { | ||
| Name string `json:"name,omitempty"` | ||
| Namespace string `json:"namespace,omitempty"` | ||
| } | ||
|
|
||
| type EffectPolicy struct { | ||
| Type EffectPolicyType `json:"type,omitempty"` | ||
| PostHook *PostHookConfig `json:"postHook,omitempty"` | ||
| } | ||
|
|
||
| type EffectPolicyType string | ||
|
|
||
| const ( | ||
| EffectPolicyTypeReStart EffectPolicyType = "ReStart" | ||
| EffectPolicyTypePostHook EffectPolicyType = "PostHook" | ||
| EffectPolicyTypeHotUpdate EffectPolicyType = "HotUpdate" | ||
| ) | ||
|
|
||
| type PostHookConfig struct { | ||
| HTTPGet []*corev1.HTTPGetAction `json:"httpGet,omitempty"` | ||
| TCPSocket []*corev1.TCPSocketAction `json:"tcpSocket,omitempty"` | ||
| } | ||
|
|
||
| type ConfigMapSetUpdateStrategy struct { | ||
| Partition *intstr.IntOrString `json:"partition,omitempty"` | ||
| MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"` | ||
| MatchLabelKeys []string `json:"matchLabelKeys,omitempty"` | ||
| } | ||
|
|
||
| // ConfigMapSetStatus defines the observed state of ConfigMapSet | ||
| type ConfigMapSetStatus struct { | ||
| CurrentCustomVersion string `json:"currentCustomVersion,omitempty"` | ||
| CurrentRevision string `json:"currentRevision,omitempty"` | ||
| ExpectedUpdatedReplicas int32 `json:"expectedUpdatedReplicas,omitempty"` | ||
| ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
| ReadyReplicas int32 `json:"readyReplicas,omitempty"` | ||
| Replicas int32 `json:"replicas,omitempty"` | ||
| UpdateCustomVersion string `json:"updateCustomVersion,omitempty"` | ||
| UpdateRevision string `json:"updateRevision,omitempty"` | ||
| UpdatedReadyReplicas int32 `json:"updatedReadyReplicas,omitempty"` | ||
| UpdatedReplicas int32 `json:"updatedReplicas,omitempty"` | ||
| } | ||
|
|
||
| // +genclient | ||
| // +k8s:openapi-gen=true | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:printcolumn:name="REPLICAS",type="integer",JSONPath=".status.replicas",description="The number of pods matched." | ||
| // +kubebuilder:printcolumn:name="UPDATED",type="integer",JSONPath=".status.updatedReplicas",description="The number of pods matched and updated." | ||
| // +kubebuilder:printcolumn:name="READY",type="integer",JSONPath=".status.readyReplicas",description="The number of pods matched and ready." | ||
| // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created." | ||
|
|
||
| // ConfigMapSet is the Schema for the configmapsets API | ||
| type ConfigMapSet struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec ConfigMapSetSpec `json:"spec,omitempty"` | ||
| Status ConfigMapSetStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // ConfigMapSetList contains a list of ConfigMapSet | ||
| type ConfigMapSetList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []ConfigMapSet `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&ConfigMapSet{}, &ConfigMapSetList{}) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.