Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Adds kubectl rollout operations to match Java client and kubectl CLI functionality for managing deployment, daemonset, and statefulset rollouts.

Implementation

Core operations (AsyncKubectl.Rollout.cs):

  • RolloutRestartAsync<T> - triggers rollout via restart annotation (supports V1Deployment, V1DaemonSet, V1StatefulSet)
  • RolloutStatusAsync<T> - returns detailed rollout progress status for all workload types
  • RolloutHistoryAsync<T> - retrieves revision history with change-cause annotations
  • RolloutUndoAsync<T> - rolls back to specified or previous revision (Deployment only)
  • RolloutPauseAsync<T> / RolloutResumeAsync<T> - controls deployment rollouts (Deployment only)

Synchronous wrappers (Kubectl.Rollout.cs):

  • Generic sync wrappers following existing patterns (RolloutRestart, RolloutStatus, etc.)

Tests (KubectlTests.Rollout.cs):

  • Coverage for all operations across resource types

API Design

The API uses generic type parameters following the same pattern as existing Get<T> and List<T> methods, providing a clean and consistent interface:

using var kubernetes = new Kubernetes(config);
var kubectl = new Kubectl(kubernetes);

// Restart workloads
kubectl.RolloutRestart<V1Deployment>("my-app", "production");
kubectl.RolloutRestart<V1DaemonSet>("my-daemon", "default");
kubectl.RolloutRestart<V1StatefulSet>("my-sts", "default");

// Check status
var status = kubectl.RolloutStatus<V1Deployment>("my-app", "production");
// Returns: "deployment \"my-app\" successfully rolled out"

// View history
var history = kubectl.RolloutHistory<V1Deployment>("my-app", "production");

// Deployment-specific operations
kubectl.RolloutPause<V1Deployment>("my-app", "production");
kubectl.RolloutResume<V1Deployment>("my-app", "production");
kubectl.RolloutUndo<V1Deployment>("my-app", "production");

Technical Details

  • Uses JSON patch operations for resource updates
  • Generic type parameters with runtime type checking for resource-specific operations
  • Extracts label selectors via shared helper method
  • Defines annotation keys as constants (RestartedAtAnnotation, RevisionAnnotation, ChangeCauseAnnotation)
  • Handles ReplicaSets for deployments, ControllerRevisions for daemonsets/statefulsets
Original prompt

This section details on the original issue you should resolve

<issue_title>Implement KubectlRollout</issue_title>
<issue_description>Similar to this code in the Java client:
https://github.com/kubernetes-client/java/blob/master/extended/src/main/java/io/kubernetes/client/extended/kubectl/KubectlRollout.java

And this cli command:
https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/

We should support rollout in the Kubectl Library.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 10, 2025
…, pause, and resume methods

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from brendandburns. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 10, 2025
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 10, 2025
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for KubectlRollout in Kubectl Library Implement KubectlRollout for deployment lifecycle management Dec 10, 2025
Copilot AI requested a review from brendandburns December 10, 2025 20:49
@brendandburns
Copy link
Contributor

@copilot please update this PR to use a single method signature with different typed parameters instead of a separate method name for Deployments, StatefulSets, etc.

Changed API from separate methods per resource type to generic methods:
- RolloutRestart<T>, RolloutStatus<T>, RolloutHistory<T>
- RolloutPause<T>, RolloutResume<T>, RolloutUndo<T>

Usage example:
  kubectl.RolloutRestart<V1Deployment>("my-app", "production");
  kubectl.RolloutStatus<V1DaemonSet>("my-daemon", "default");

This provides a cleaner API that follows the pattern used by Get<T> and List<T>.

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 10, 2025

@copilot please update this PR to use a single method signature with different typed parameters instead of a separate method name for Deployments, StatefulSets, etc.

Done! Refactored to use generic type parameters instead of separate method names. The new API follows the same pattern as Get and List:

kubectl.RolloutRestart<V1Deployment>("my-app", "production");
kubectl.RolloutStatus<V1DaemonSet>("my-daemon", "default");
kubectl.RolloutHistory<V1StatefulSet>("my-sts", "default");

Changes in commit f820e76.

Copilot AI changed the title Implement KubectlRollout for deployment lifecycle management Implement KubectlRollout with generic type parameters for deployment lifecycle management Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement KubectlRollout

3 participants