-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Workloads V1 #53679
Workloads V1 #53679
Conversation
PR desc needs to be updated: replace DaemonSet with StatefulSet. Need to remove DS from release note too since it's already done. |
StatefulSet is there, but we will probably do a single release note for the entire API. |
/retest |
@liggitt this version is without the scale |
/test pull-kubernetes-unit |
@kow3ns I thought we were going to do this in a branch? |
@bgrant0607 we are still trying to get the branch working and we didn't want to stop all development until then. The branch still can't run tests. |
/test pull-kubernetes-unit |
/retest |
/retest |
pkg/apis/apps/v1/defaults.go
Outdated
// - RevisionHistoryLimit set to 10 (not set in extensions) | ||
// - ProgressDeadlineSeconds set to 600s (not set in extensions) | ||
func SetDefaults_Deployment(obj *appsv1.Deployment) { | ||
// Set appsv1beta2.DeploymentSpec.Replicas to 1 if it is not set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "appsv1"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'm going to rebase the update into the first commit on the PR.
@@ -1350,7 +1350,7 @@ run_kubectl_get_tests() { | |||
kube::test::if_has_string "${output_message}" "/api/v1/namespaces/default/pods 200 OK" | |||
kube::test::if_has_string "${output_message}" "/api/v1/namespaces/default/replicationcontrollers 200 OK" | |||
kube::test::if_has_string "${output_message}" "/api/v1/namespaces/default/services 200 OK" | |||
kube::test::if_has_string "${output_message}" "/apis/apps/v1beta1/namespaces/default/statefulsets 200 OK" | |||
kube::test::if_has_string "${output_message}" "/apis/apps/v1/namespaces/default/statefulsets 200 OK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this test be running against clusters that don't have apps/v1
enabled yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command tests are always written expecting a specific version of group version kind to be returned. That version has always been dependent on the packaged kubectl and apiserver configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
Mention that |
@@ -330,19 +330,21 @@ func (f *ring1Factory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) | |||
func (f *ring1Factory) HistoryViewer(mapping *meta.RESTMapping) (kubectl.HistoryViewer, error) { | |||
mappingVersion := mapping.GroupVersionKind.GroupVersion() | |||
clientset, err := f.clientAccessFactory.ClientSetForVersion(&mappingVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check the returned err
pkg/kubectl/history.go
Outdated
} | ||
return nil, fmt.Errorf("no history viewer has been implemented for %q", kind) | ||
} | ||
|
||
type DeploymentHistoryViewer struct { | ||
c clientset.Interface | ||
ic internalclientset.Interface | ||
ec kubernetes.Interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubernetes.Clienset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need any implementation detail in this context so I think we should go with interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for interface
pkg/kubectl/history.go
Outdated
@@ -147,14 +149,15 @@ func printTemplate(template *v1.PodTemplateSpec) (string, error) { | |||
} | |||
|
|||
type DaemonSetHistoryViewer struct { | |||
c clientset.Interface | |||
id internalclientset.Interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how much is preexisting, but kubectl should be moving toward dealing in external versions
cc @kubernetes/sig-cli-pr-reviews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just going to go ahead and move the rollbackers and history to external version (v1beta1) and unwire the internal. We know the client is moving in this direction, and we might as well help the process along while there is time.
@@ -52,26 +53,27 @@ type HistoryViewer interface { | |||
ViewHistory(namespace, name string, revision int64) (string, error) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we don't need internal clientset at all in history viewer, do we?
@@ -54,20 +55,21 @@ type Rollbacker interface { | |||
Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64, dryRun bool) (string, error) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need ic here either
if err != nil { | ||
return nil, err | ||
} | ||
return kubectl.HistoryViewerFor(mapping.GroupVersionKind.GroupKind(), clientset) | ||
return kubectl.HistoryViewerFor(mapping.GroupVersionKind.GroupKind(), clientset, external) | ||
} | ||
|
||
func (f *ring1Factory) Rollbacker(mapping *meta.RESTMapping) (kubectl.Rollbacker, error) { | ||
mappingVersion := mapping.GroupVersionKind.GroupVersion() | ||
clientset, err := f.clientAccessFactory.ClientSetForVersion(&mappingVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check err
@@ -330,19 +330,21 @@ func (f *ring1Factory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) | |||
func (f *ring1Factory) HistoryViewer(mapping *meta.RESTMapping) (kubectl.HistoryViewer, error) { | |||
mappingVersion := mapping.GroupVersionKind.GroupVersion() | |||
clientset, err := f.clientAccessFactory.ClientSetForVersion(&mappingVersion) | |||
external, err := f.clientAccessFactory.KubernetesClientSet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming nit: if we need both internal and external clientset, name the internal one "internal" or name the external one "externalClientset"
/lgtm |
@kow3ns what would be needed for users to migrate from v1beta1 to v1 for these objects ? |
@krmayankk the storage formats are not changed. You can consume the API from apps/v1. The deprecation cycle for extensions/v1, apps/v1beta1, and apps/v1beta2 will take into account that users are currently depending on them in production. Subsequent releases will include instructions on how to upgrade storage formats in order to migrate existing workloads to a newer version. |
…Set kinds to the apps/v1 group version.
…fulSet History and Rollback and updates test-cmd for new versions
expectedGVK: gvkP("extensions", "v1beta1", "ReplicaSet"), | ||
}, | ||
gvr("apps", "v1", "controllerrevisions"): { | ||
stub: `{"metadata":{"name":"crs3"},"data":{"name":"abc","namespace":"default","creationTimestamp":null,"Spec":{"Replicas":0,"Selector":{"matchLabels":{"foo":"bar"}},"Template":{"creationTimestamp":null,"labels":{"foo":"bar"},"Spec":{"Volumes":null,"InitContainers":null,"Containers":null,"RestartPolicy":"Always","TerminationGracePeriodSeconds":null,"ActiveDeadlineSeconds":null,"DNSPolicy":"ClusterFirst","NodeSelector":null,"ServiceAccountName":"","AutomountServiceAccountToken":null,"NodeName":"","SecurityContext":null,"ImagePullSecrets":null,"Hostname":"","Subdomain":"","Affinity":null,"SchedulerName":"","Tolerations":null,"HostAliases":null}},"VolumeClaimTemplates":null,"ServiceName":""},"Status":{"ObservedGeneration":null,"Replicas":0}},"revision":0}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this stub is using JSON generated from an internal object (note the capitalized keys). this is pre-existing in the other stub tests and can be fixed as a follow up.
/approve |
/approve approve for hack |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: foxish, janetkuo, kow3ns, liggitt, pwittrock Associated issue: 353 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Automatic merge from submit-queue (batch tested with PRs 55792, 58342). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Promote Statefulset controller and its e2e tests to use apps/v1 **What this PR does / why we need it**: Promotes the statefulset controller to use to use the latest apps group [apps/v1](#53679) **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # #55714 **Special notes for your reviewer**: * Listerexpansion for v1 `k8s.io/client-go/listers/apps/v1` (was recently done for v1beta2) * `v1beta2` && `v1` had `ObservedGeneration` as `int64` where as `v1beta1` and rest of the code (including conversion) is expecting `ObservedGeneration` to be `*int64` ``` type StatefulSetStatus struct { // observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the // StatefulSet's generation, which is updated on mutation by the API Server. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` ``` * for kubectl's `rollback` and `history` commands a couple functions have been duplicated to allow us to use `v1` version instead of `v1beta1` for statefulsets, while the older functions are still used by other controllers. We should be able to remove these duplicates once all the controllers are moved. If this aligns with the plan then i could move other controllers too. cc: @kow3ns **Release note**: ```release-note NONE ```
What this PR does / why we need it: This PR promotes the Deployment, ReplicaSet, and DaemonSet StatefulSet, ControllerRevision kinds to the apps/v1 group version.
kubernetes/enhancements#353
Special notes for your reviewer:
There will be at least two followups to this PR. The first to add a scale sub-resource when the correct location is resolved, and the second to deal with Conditions in the workloads API.
While it would have been preferable to move the kinds individually providing a lesser burden on reviewers, this proved impracticable due to the intricacies of version resolution in kubectl for objects of the different kinds in the same group.