community.kubernetes.k8s_scale – Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.¶
Note
This plugin is part of the community.kubernetes collection (version 1.1.1).
To install it use: ansible-galaxy collection install community.kubernetes
.
To use it in a playbook, specify: community.kubernetes.k8s_scale
.
Synopsis¶
Similar to the kubectl scale command. Use to set the number of replicas for a Deployment, ReplicaSet, or Replication Controller, or the parallelism attribute of a Job. Supports check mode.
Note
This module has a corresponding action plugin.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.7
openshift >= 0.6
PyYAML >= 3.11
Parameters¶
Notes¶
Note
The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python
To avoid SSL certificate validation errors when
validate_certs
is True, the full certificate chain for the API server must be provided viaca_cert
or in the kubeconfig file.
Examples¶
- name: Scale deployment up, and extend timeout
community.kubernetes.k8s_scale:
api_version: v1
kind: Deployment
name: elastic
namespace: myproject
replicas: 3
wait_timeout: 60
- name: Scale deployment down when current replicas match
community.kubernetes.k8s_scale:
api_version: v1
kind: Deployment
name: elastic
namespace: myproject
current_replicas: 3
replicas: 2
- name: Increase job parallelism
community.kubernetes.k8s_scale:
api_version: batch/v1
kind: job
name: pi-with-timeout
namespace: testing
replicas: 2
# Match object using local file or inline definition
- name: Scale deployment based on a file from the local filesystem
community.kubernetes.k8s_scale:
src: /myproject/elastic_deployment.yml
replicas: 3
wait: no
- name: Scale deployment based on a template output
community.kubernetes.k8s_scale:
resource_definition: "{{ lookup('template', '/myproject/elastic_deployment.yml') | from_yaml }}"
replicas: 3
wait: no
- name: Scale deployment based on a file from the Ansible controller filesystem
community.kubernetes.k8s_scale:
resource_definition: "{{ lookup('file', '/myproject/elastic_deployment.yml') | from_yaml }}"
replicas: 3
wait: no
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Chris Houseknecht (@chouseknecht)
Fabian von Feilitzsch (@fabianvf)