When I wanted to use kubectl to restart a deployment (rancher) in the cattle-system namespace, I had to raise an eyebrow when I got the following error:
ck@mint ~ $ kubectl rollout restart deployment rancher -n cattle-system
error: unknown command "restart deployment rancher"
In case you wonder what this command is supposed to do inside a Kubernetes cluster:
In Kubernetes, kubectl rollout restart is a command used to start a new rollout process for three specific Kubernetes objects: Deployment, DaemonSet, and StatefulSet. A rollout process essentially means a gradual, step-by-step recreation of Pods — The old Pods are not removed entirely until the new Pods are running successfully. This process ensures that your application remains available throughout the restart process. - kodekloud.com/blog/kubectl-rollout-restart/
Turns out this sub-command "rollout restart" does indeed not exist:
ck@mint ~ $ kubectl rollout --help
Manage the rollout of a resource.
Valid resource types include:
* deployments
* daemonsets
* statefulsets
Examples:
# Rollback to the previous deployment
kubectl rollout undo deployment/abc
# Check the rollout status of a daemonset
kubectl rollout status daemonset/foo
Available Commands:
history View rollout history
pause Mark the provided resource as paused
resume Resume a paused resource
status Show the status of the rollout
undo Undo a previous rollout
Usage:
kubectl rollout SUBCOMMAND [options]
Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
But it also turned out that this way a very old version of kubectl:
ck@mint ~ $ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.6", GitCommit:"96fac5cd13a5dc064f7d9f4f23030a6aeface6cc", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:49Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
On this machine, kubectl 1.14.6 is installed - that's old (certainly when looking at the Kubernetes release schedules)!
The rollout restart sub-command was added in Kubernetes 1.15 and mentions the following in the Kubernetes v1.15 release notes:
The kubectl command is supposed to be backward-compatible (to a high degree anyway) and can/should be able to communicate with clusters running on a different version. After I installed and tested the current release (1.29.1), the command worked:
ck@mint ~ $ kubectl version | head -n 1
Client Version: v1.29.1
ck@mint ~ $ kubectl rollout restart deployment rancher -n cattle-system
deployment.apps/rancher restarted
The pods of the rancher deployment correctly restarted after this rollout, one after another:
ck@mint ~ $ kubectl get pod -n cattle-system
NAME READY STATUS RESTARTS AGE
rancher-54c8bdb5fc-czmxb 0/1 Running 0 6s
rancher-54c8bdb5fc-k79xs 0/1 Running 0 6s
rancher-5f4c59dcb8-8qr5r 1/1 Running 1 357d
rancher-5f4c59dcb8-vn7gr 1/1 Running 4 357d
rancher-webhook-6fb7fddc84-mrpvp 1/1 Running 0 29m
... until all pods were restarted and deemed running (and the old pods automatically deleted):
ck@mint ~ $ kubectl get pod -n cattle-system
NAME READY STATUS RESTARTS AGE
rancher-54c8bdb5fc-czmxb 1/1 Running 0 30m
rancher-54c8bdb5fc-k79xs 1/1 Running 0 30m
rancher-54c8bdb5fc-l45tl 1/1 Running 0 30m
rancher-webhook-6fb7fddc84-mrpvp 1/1 Running 0 59m
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder