ansible-collections / kubernetes.core

The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves.
Other
215 stars 135 forks source link

Kubernetes module add rollout tasks #567

Open Theprim0 opened 1 year ago

Theprim0 commented 1 year ago
SUMMARY

It would be interesting to include tasks into kubernetes.core to interact with ROLLOUT.

ISSUE TYPE
COMPONENT NAME

kubectl rollout

rollout history, rollout restart, etc...

ADDITIONAL INFORMATION
Tasks as we would do with CLI:
kubectl rollout status Deployment/mi-deployment
gravesm commented 1 year ago

Thanks for filing a feature request. Could you be a bit more specific about what you would like to be able to do? I believe the collection should already support the functionality provided by kubectl rollout. The information from status and history should be available from the k8s_info module, but in a machine actionable format. The k8s_rollback module does what undo does. pause and resume can both be accomplished with a simple k8s_json_patch operation to set the /spec/paused property. The only thing that can't be done easily with the collection is the rolling restart.

MarceloFCandido commented 1 year ago

Thanks for filing a feature request. Could you be a bit more specific about what you would like to be able to do? I believe the collection should already support the functionality provided by kubectl rollout. The information from status and history should be available from the k8s_info module, but in a machine actionable format. The k8s_rollback module does what undo does. pause and resume can both be accomplished with a simple k8s_json_patch operation to set the /spec/paused property. The only thing that can't be done easily with the collection is the rolling restart.

@gravesm, which way do you suggest to do do rollout restart with the collection? I would like to apply the rollout restart that can be seen here but without using the ansible.builtin.shell module.

Theprim0 commented 1 year ago

@gravesm exactly, i see k8s_rollback module exists, but I mean "rollout". As @MarceloFCandido says, we can't acomplish "rollout restart" with kubernetes.core module neither with k8s_rollback module.

jdavis-politico commented 1 year ago

Came looking for this too. Glad it's being looked into. Thanks.

grsiepka commented 1 year ago

+1 for this feature, but wonder if in the meantime, could you use the kubernetes.core.k8s_scale module to scale the deployment to 0, then back to what it was?

JossWhittle commented 1 year ago

The following works for anyone else who finds this thread.

kubectl rollout status -w deployment/foo-bar -n foo

becomes...

- name: "k8s wait for deployment/foo-bar rollout"
  kubernetes.core.k8s_info:
    kind: Rollout
    namespace: "foo"
    name: "deployment/foo-bar"
    wait: true
    wait_condition:
      type: Succeeded

Maybe this could be added to the examples? https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_info_module.html#examples

lordofthejars commented 1 year ago

+1 to this feature. I need to restart a deployment because of a change in a ConfigMap.

besmirzanaj commented 1 year ago

+1 for this. seems a very useful feature

ShubhamRasal commented 1 year ago

+1 for this. seems a very useful feature

vcazsdk commented 1 year ago

+1 to this feature

psyntium commented 1 year ago

+1

mohag commented 1 year ago
kubectl rollout status -w deployment/foo-bar -n foo

becomes...

- name: "k8s wait for deployment/foo-bar rollout"
  kubernetes.core.k8s_info:
    kind: Rollout
    namespace: "foo"
    name: "deployment/foo-bar"
    wait: true
    wait_condition:
      type: Succeeded

That gives me a (green) output saying:

Failed to find API for resource with apiVersion "v1" and kind "Rollout"
dyegoe commented 12 months ago

+1

I was looking into restarting ArgoCD deployment after patching the configmap

But, meanwhile, I found a way to restart a deployment:

- name: Restart ArgoCD repo-server
  kubernetes.core.k8s:
    state: patched
    kind: Deployment
    name: argocd-repo-server
    namespace: "{{ argocd_namespace }}"
    definition:
      spec:
        template:
          metadata:
            annotations:
              kubectl.kubernetes.io/restartedAt: "{{ now(fmt='%Y-%m-%dT%H:%M:%SZ') }}"
owwweiha commented 3 months ago

+1