Kubernetes Core 6.4.0: Helm v4 Support & k8s_drain Improvements
By Luca Berton · Published 2024-01-01 · Category: installation
kubernetes.core 6.4.0 collection release adds Helm v4 compatibility and improved k8s_drain check mode. Upgrade guide with practical examples.
Introduction
The kubernetes.core 6.4.0 collection has been released with two significant improvements: Helm v4 compatibility across all Helm modules and enhanced k8s_drain behavior with check mode support.
This update is important for teams using Ansible to manage Kubernetes clusters, especially those planning to adopt Helm v4.
See also: Ansible for Kubernetes: Automate K8s Cluster Management and Application Deployment
What's New in 6.4.0
Helm v4 Compatibility
All Helm modules now work with Helm v4, ensuring forward compatibility as the Helm ecosystem evolves:
- name: Deploy application with Helm (v4 compatible)
hosts: localhost
connection: local
collections:
- kubernetes.core
tasks:
- name: Add Helm repository
kubernetes.core.helm_repository:
name: bitnami
repo_url: https://charts.bitnami.com/bitnami
- name: Install nginx using Helm
kubernetes.core.helm:
name: my-nginx
chart_ref: bitnami/nginx
release_namespace: web
create_namespace: true
values:
replicaCount: 3
service:
type: ClusterIP
resources:
limits:
cpu: 250m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
Improved k8s_drain with Check Mode
The k8s_drain module now handles check mode properly. When you explicitly allow evicting unmanaged pods, pods with local storage, or DaemonSet-managed pods, those cases are reported as informational output instead of warnings:
- name: Drain node for maintenance
hosts: localhost
connection: local
tasks:
- name: Cordon the node first
kubernetes.core.k8s:
kind: Node
name: worker-node-01
definition:
spec:
unschedulable: true
- name: Drain node with proper handling
kubernetes.core.k8s_drain:
name: worker-node-01
delete_options:
ignore_daemonsets: true
delete_emptydir_data: true
force: true
grace_period: 60
state: drain
- name: Perform maintenance tasks
ansible.builtin.debug:
msg: "Node drained — ready for maintenance"
- name: Uncordon after maintenance
kubernetes.core.k8s:
kind: Node
name: worker-node-01
definition:
spec:
unschedulable: false
Upgrading to 6.4.0
# Upgrade the collection
ansible-galaxy collection install kubernetes.core:==6.4.0 --force
# Or add to requirements.yml
cat >> requirements.yml << 'EOF'
collections:
- name: kubernetes.core
version: ">=6.4.0"
EOF
ansible-galaxy collection install -r requirements.yml
Automate the upgrade:
- name: Upgrade kubernetes.core collection
hosts: localhost
connection: local
tasks:
- name: Install kubernetes.core 6.4.0
ansible.builtin.command:
cmd: ansible-galaxy collection install kubernetes.core:==6.4.0 --force
register: install_result
- name: Verify installation
ansible.builtin.command:
cmd: ansible-galaxy collection list kubernetes.core
register: version_check
- name: Display version
ansible.builtin.debug:
var: version_check.stdout_lines
See also: Ansible for Kubernetes: Deploy, Manage, and Automate K8s Clusters Complete Guide
Common Kubernetes Automation Patterns
Rolling Deployment
- name: Rolling deployment with zero downtime
hosts: localhost
connection: local
tasks:
- name: Update deployment image
kubernetes.core.k8s:
state: present
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: production
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
spec:
containers:
- name: myapp
image: "myapp:{{ app_version }}"
- name: Wait for rollout to complete
kubernetes.core.k8s_info:
kind: Deployment
name: myapp
namespace: production
register: deployment
until: >
deployment.resources[0].status.readyReplicas | default(0)
== deployment.resources[0].spec.replicas
retries: 30
delay: 10
Helm Release Management
- name: Manage multiple Helm releases
hosts: localhost
connection: local
vars:
helm_releases:
- name: monitoring
chart: prometheus-community/kube-prometheus-stack
namespace: monitoring
values:
grafana:
enabled: true
- name: ingress
chart: ingress-nginx/ingress-nginx
namespace: ingress-nginx
values:
controller:
replicaCount: 2
tasks:
- name: Deploy Helm releases
kubernetes.core.helm:
name: "{{ item.name }}"
chart_ref: "{{ item.chart }}"
release_namespace: "{{ item.namespace }}"
create_namespace: true
values: "{{ item.values }}"
loop: "{{ helm_releases }}"
FAQ
Is kubernetes.core 6.4.0 included in Ansible 13.6.0?
Check with ansible-galaxy collection list kubernetes.core. If your version is older, upgrade manually with ansible-galaxy collection install kubernetes.core:==6.4.0 --force.
Does Helm v4 support require changes to my existing playbooks?
No. The 6.4.0 update adds forward compatibility — existing Helm v3 playbooks continue to work without modification.
What Python packages are required?
The kubernetes.core collection requires the kubernetes Python package and optionally helm CLI for Helm modules.
See also: Ansible Kubernetes (k8s) Module: Manage K8s Resources (Guide)
Conclusion
kubernetes.core 6.4.0 is a solid release that prepares your Ansible-Kubernetes automation for the Helm v4 era while improving operational safety with better drain handling. Upgrade your collection to take advantage of these improvements.
Related Articles
• Ansible for Kubernetes Management • Ansible vs Kubernetes: Comparison Guide • Ansible CI/CD Pipeline IntegrationCategory: installation