mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-11 20:12:18 +00:00
Compare commits
1 Commits
6.4.0
...
stable-2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b8b3fa1ee |
141
.github/workflows/ci.yml
vendored
141
.github/workflows/ci.yml
vendored
@@ -1,141 +0,0 @@
|
|||||||
---
|
|
||||||
name: CI
|
|
||||||
'on':
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 6 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
sanity:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python_version: ['3.7']
|
|
||||||
ansible_version: ['stable-2.11', 'stable-2.10', 'stable-2.9', 'devel']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
- name: Check ansible version
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: ansible/ansible
|
|
||||||
ref: ${{ matrix.ansible_version }}
|
|
||||||
path: ansible_collections/kubernetes/core/ansible
|
|
||||||
|
|
||||||
- name: Run sanity tests on Python ${{ matrix.python_version }}
|
|
||||||
run: source ./ansible/hacking/env-setup && make test-sanity PYTHON_VERSION=${{ matrix.python_version }}
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
integration:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
# Our old integration tests fail under newer Python versions.
|
|
||||||
python_version: ['3.6']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
- name: Install ansible base (devel branch)
|
|
||||||
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
|
|
||||||
|
|
||||||
- name: Run integration tests on Python ${{ matrix.python_version }}
|
|
||||||
run: make test-integration PYTHON_VERSION=${{ matrix.python_version }}
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Generate coverage report.
|
|
||||||
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- uses: codecov/codecov-action@v1
|
|
||||||
with:
|
|
||||||
fail_ci_if_error: false
|
|
||||||
|
|
||||||
molecule:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python_version: ['3.7']
|
|
||||||
ansible_version: ['==2.9.*', '==2.10.*', '']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up KinD cluster
|
|
||||||
uses: engineerd/setup-kind@v0.5.0
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
# The 3.3.0 release of molecule introduced a breaking change. See
|
|
||||||
# https://github.com/ansible-community/molecule/issues/3083
|
|
||||||
- name: Install molecule and kubernetes dependencies
|
|
||||||
run: pip install ansible${{ matrix.ansible_version }} "molecule<3.3.0" yamllint kubernetes flake8 jsonpatch
|
|
||||||
|
|
||||||
# The latest release doesn't work with Molecule currently.
|
|
||||||
# See: https://github.com/ansible-community/molecule/issues/2757
|
|
||||||
# - name: Install ansible base, latest release.
|
|
||||||
# run: |
|
|
||||||
# pip uninstall -y ansible
|
|
||||||
# pip install --pre ansible-base
|
|
||||||
|
|
||||||
# The devel branch doesn't work with Molecule currently.
|
|
||||||
# See: https://github.com/ansible-community/molecule/issues/2757
|
|
||||||
# - name: Install ansible base (devel branch)
|
|
||||||
# run: |
|
|
||||||
# pip uninstall -y ansible
|
|
||||||
# pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
|
|
||||||
- name: Create default collection path symlink
|
|
||||||
run: |
|
|
||||||
mkdir -p /home/runner/.ansible
|
|
||||||
ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections
|
|
||||||
|
|
||||||
- name: Run molecule default test scenario
|
|
||||||
run: make test-molecule
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
unit:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python_version: ['3.7']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
- name: Install ansible base (devel branch)
|
|
||||||
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
|
|
||||||
|
|
||||||
- name: Run unit tests on Python ${{ matrix.python_version }}
|
|
||||||
run: make test-unit PYTHON_VERSION=${{ matrix.python_version }}
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -13,3 +13,9 @@ changelogs/.plugin-cache.yaml
|
|||||||
tests/output
|
tests/output
|
||||||
tests/integration/cloud-config-*
|
tests/integration/cloud-config-*
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
|
tests/integration/*-chart-*.tgz
|
||||||
|
|
||||||
|
# ansible-test generated file
|
||||||
|
tests/integration/inventory
|
||||||
|
tests/integration/*-*.yml
|
||||||
|
|||||||
@@ -1,254 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Converge
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
|
|
||||||
collections:
|
|
||||||
- kubernetes.core
|
|
||||||
|
|
||||||
vars_files:
|
|
||||||
- vars/main.yml
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Verify cluster is working.
|
|
||||||
k8s_info:
|
|
||||||
namespace: kube-system
|
|
||||||
kind: Pod
|
|
||||||
register: pod_list
|
|
||||||
|
|
||||||
- name: Verify cluster has more than 5 pods running.
|
|
||||||
assert:
|
|
||||||
that: (pod_list.resources | count) > 5
|
|
||||||
|
|
||||||
- name: Include access_review.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/access_review.yml
|
|
||||||
apply:
|
|
||||||
tags: [ access_review, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include append_hash.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/append_hash.yml
|
|
||||||
apply:
|
|
||||||
tags: [ append_hash, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include apply.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/apply.yml
|
|
||||||
apply:
|
|
||||||
tags: [ apply, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include cluster_info.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/cluster_info.yml
|
|
||||||
apply:
|
|
||||||
tags: [ cluster_info, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include crd.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/crd.yml
|
|
||||||
apply:
|
|
||||||
tags: [ crd, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include delete.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/delete.yml
|
|
||||||
apply:
|
|
||||||
tags: [ delete, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include exec.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/exec.yml
|
|
||||||
apply:
|
|
||||||
tags: [ exec, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include full.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/full.yml
|
|
||||||
apply:
|
|
||||||
tags: [ full, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include gc.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/gc.yml
|
|
||||||
apply:
|
|
||||||
tags: [ gc, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include info.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/info.yml
|
|
||||||
apply:
|
|
||||||
tags: [ info, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include json_patch.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/json_patch.yml
|
|
||||||
apply:
|
|
||||||
tags: [ json_patch, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include lists.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/lists.yml
|
|
||||||
apply:
|
|
||||||
tags: [ lists, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include log.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/log.yml
|
|
||||||
apply:
|
|
||||||
tags: [ log, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include rollback.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/rollback.yml
|
|
||||||
apply:
|
|
||||||
tags: [ rollback, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include scale.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/scale.yml
|
|
||||||
apply:
|
|
||||||
tags: [ scale, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include template.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/template.yml
|
|
||||||
apply:
|
|
||||||
tags: [ template, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
- name: Include waiter.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/waiter.yml
|
|
||||||
apply:
|
|
||||||
tags: [ waiter, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
|
|
||||||
- name: Include merge_type.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/merge_type.yml
|
|
||||||
apply:
|
|
||||||
tags: [ merge_type, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
|
|
||||||
- name: Include patched.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/patched.yml
|
|
||||||
apply:
|
|
||||||
tags: [ patched, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
|
|
||||||
- name: Include lookup_k8s.yml
|
|
||||||
include_tasks:
|
|
||||||
file: tasks/lookup_k8s.yml
|
|
||||||
apply:
|
|
||||||
tags: [ lookup, k8s ]
|
|
||||||
tags:
|
|
||||||
- always
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- role: helm
|
|
||||||
tags:
|
|
||||||
- helm
|
|
||||||
|
|
||||||
post_tasks:
|
|
||||||
- name: Ensure namespace exists
|
|
||||||
k8s:
|
|
||||||
api_version: v1
|
|
||||||
kind: Namespace
|
|
||||||
name: inventory
|
|
||||||
|
|
||||||
- name: Add a deployment
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: inventory
|
|
||||||
namespace: inventory
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: "{{ k8s_pod_name }}"
|
|
||||||
template: "{{ k8s_pod_template }}"
|
|
||||||
wait: yes
|
|
||||||
wait_timeout: 120
|
|
||||||
vars:
|
|
||||||
k8s_pod_name: inventory
|
|
||||||
k8s_pod_image: python
|
|
||||||
k8s_pod_command:
|
|
||||||
- python
|
|
||||||
- '-m'
|
|
||||||
- http.server
|
|
||||||
k8s_pod_env:
|
|
||||||
- name: TEST
|
|
||||||
value: test
|
|
||||||
|
|
||||||
- meta: refresh_inventory
|
|
||||||
|
|
||||||
- name: Verify inventory and connection plugins
|
|
||||||
hosts: namespace_inventory_pods
|
|
||||||
gather_facts: no
|
|
||||||
|
|
||||||
vars:
|
|
||||||
file_content: |
|
|
||||||
Hello world
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: End play if host not running (TODO should we not add these to the inventory?)
|
|
||||||
meta: end_host
|
|
||||||
when: pod_phase != "Running"
|
|
||||||
|
|
||||||
- debug: var=hostvars
|
|
||||||
- setup:
|
|
||||||
|
|
||||||
- debug: var=ansible_facts
|
|
||||||
|
|
||||||
- name: Assert the TEST environment variable was retrieved
|
|
||||||
assert:
|
|
||||||
that: ansible_facts.env.TEST == 'test'
|
|
||||||
|
|
||||||
- name: Copy a file into the host
|
|
||||||
copy:
|
|
||||||
content: '{{ file_content }}'
|
|
||||||
dest: /tmp/test_file
|
|
||||||
|
|
||||||
- name: Retrieve the file from the host
|
|
||||||
slurp:
|
|
||||||
src: /tmp/test_file
|
|
||||||
register: slurped_file
|
|
||||||
|
|
||||||
- name: Assert the file content matches expectations
|
|
||||||
assert:
|
|
||||||
that: (slurped_file.content|b64decode) == file_content
|
|
||||||
|
|
||||||
- name: Delete inventory namespace
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
gather_facts: no
|
|
||||||
tasks:
|
|
||||||
- name: Remove inventory namespace
|
|
||||||
k8s:
|
|
||||||
api_version: v1
|
|
||||||
kind: Namespace
|
|
||||||
name: inventory
|
|
||||||
state: absent
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
---
|
|
||||||
driver:
|
|
||||||
name: delegated
|
|
||||||
options:
|
|
||||||
managed: false
|
|
||||||
login_cmd_template: 'docker exec -ti {instance} bash'
|
|
||||||
ansible_connection_options:
|
|
||||||
ansible_connection: docker
|
|
||||||
lint: |
|
|
||||||
set -e
|
|
||||||
yamllint .
|
|
||||||
flake8
|
|
||||||
platforms:
|
|
||||||
- name: instance-kind
|
|
||||||
provisioner:
|
|
||||||
name: ansible
|
|
||||||
log: true
|
|
||||||
config_options:
|
|
||||||
inventory:
|
|
||||||
enable_plugins: kubernetes.core.k8s
|
|
||||||
lint: {}
|
|
||||||
inventory:
|
|
||||||
hosts:
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
host_vars:
|
|
||||||
localhost:
|
|
||||||
ansible_python_interpreter: '{{ ansible_playbook_python }}'
|
|
||||||
env:
|
|
||||||
ANSIBLE_FORCE_COLOR: 'true'
|
|
||||||
options:
|
|
||||||
vvv: True
|
|
||||||
scenario:
|
|
||||||
name: default
|
|
||||||
test_sequence:
|
|
||||||
- dependency
|
|
||||||
- lint
|
|
||||||
- syntax
|
|
||||||
- converge
|
|
||||||
- verify
|
|
||||||
dependency:
|
|
||||||
name: galaxy
|
|
||||||
options:
|
|
||||||
requirements-file: requirements.yml
|
|
||||||
@@ -1 +1,4 @@
|
|||||||
kubernetes-validate
|
kubernetes-validate
|
||||||
|
coverage==4.5.4
|
||||||
|
pytest
|
||||||
|
pytest-xdist
|
||||||
|
|||||||
7
tests/integration/targets/helm/aliases
Normal file
7
tests/integration/targets/helm/aliases
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
slow
|
||||||
|
time=609
|
||||||
|
helm_info
|
||||||
|
helm_repository
|
||||||
|
helm_template
|
||||||
|
helm_plugin
|
||||||
|
helm_plugin_info
|
||||||
@@ -3,9 +3,6 @@ helm_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.t
|
|||||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||||
helm_namespace: helm
|
helm_namespace: helm
|
||||||
|
|
||||||
tiller_namespace: tiller
|
|
||||||
tiller_cluster_role: cluster-admin
|
|
||||||
|
|
||||||
chart_test: "ingress-nginx"
|
chart_test: "ingress-nginx"
|
||||||
chart_test_local_path: "nginx-ingress"
|
chart_test_local_path: "nginx-ingress"
|
||||||
chart_test_version: 3.8.0
|
chart_test_version: 3.8.0
|
||||||
@@ -9,3 +9,7 @@
|
|||||||
src: 'https://get.helm.sh/{{ helm_archive_name }}'
|
src: 'https://get.helm.sh/{{ helm_archive_name }}'
|
||||||
dest: /tmp/helm/
|
dest: /tmp/helm/
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
retries: 10
|
||||||
|
delay: 5
|
||||||
|
register: result
|
||||||
|
until: result is not failed
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
- name: Install chart while skipping CRDs
|
- name: Install chart while skipping CRDs
|
||||||
helm:
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
|
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
name: test-crds
|
name: test-crds
|
||||||
@@ -46,12 +47,14 @@
|
|||||||
# Helm won't install CRDs into an existing release, so we need to delete this, first
|
# Helm won't install CRDs into an existing release, so we need to delete this, first
|
||||||
- name: Uninstall chart
|
- name: Uninstall chart
|
||||||
helm:
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
name: test-crds
|
name: test-crds
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Install chart with CRDs
|
- name: Install chart with CRDs
|
||||||
helm:
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
|
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
name: test-crds
|
name: test-crds
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Add chart repo
|
- name: Add chart repo
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm
|
name: test_helm
|
||||||
repo_url: "{{ chart_test_repo }}"
|
repo_url: "{{ chart_test_repo }}"
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@
|
|||||||
|
|
||||||
- name: Add chart repo
|
- name: Add chart repo
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm
|
name: test_helm
|
||||||
repo_url: "{{ chart_test_repo }}"
|
repo_url: "{{ chart_test_repo }}"
|
||||||
state: absent
|
state: absent
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
block:
|
block:
|
||||||
- name: Install helm diff
|
- name: Install helm diff
|
||||||
helm_plugin:
|
helm_plugin:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
state: present
|
state: present
|
||||||
plugin_path: https://github.com/databus23/helm-diff
|
plugin_path: https://github.com/databus23/helm-diff
|
||||||
|
|
||||||
@@ -136,6 +137,7 @@
|
|||||||
|
|
||||||
- name: Uninstall helm diff
|
- name: Uninstall helm diff
|
||||||
helm_plugin:
|
helm_plugin:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
state: absent
|
state: absent
|
||||||
plugin_name: diff
|
plugin_name: diff
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
@@ -97,6 +97,7 @@
|
|||||||
|
|
||||||
- name: Gather Helm plugin info
|
- name: Gather Helm plugin info
|
||||||
helm_plugin_info:
|
helm_plugin_info:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
register: r
|
register: r
|
||||||
|
|
||||||
- name: Set sample_plugin version
|
- name: Set sample_plugin version
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: "Ensure test_helm_repo doesn't exist"
|
- name: "Ensure test_helm_repo doesn't exist"
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm_repo
|
name: test_helm_repo
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Add test_helm_repo chart repository
|
- name: Add test_helm_repo chart repository
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm_repo
|
name: test_helm_repo
|
||||||
repo_url: "{{ chart_test_repo }}"
|
repo_url: "{{ chart_test_repo }}"
|
||||||
register: repository
|
register: repository
|
||||||
@@ -17,6 +19,7 @@
|
|||||||
|
|
||||||
- name: Check idempotency
|
- name: Check idempotency
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm_repo
|
name: test_helm_repo
|
||||||
repo_url: "{{ chart_test_repo }}"
|
repo_url: "{{ chart_test_repo }}"
|
||||||
register: repository
|
register: repository
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
|
|
||||||
- name: Failed to add repository with the same name
|
- name: Failed to add repository with the same name
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm_repo
|
name: test_helm_repo
|
||||||
repo_url: "https://other-charts.url"
|
repo_url: "https://other-charts.url"
|
||||||
register: repository_errors
|
register: repository_errors
|
||||||
@@ -40,6 +44,7 @@
|
|||||||
|
|
||||||
- name: Remove test_helm_repo chart repository
|
- name: Remove test_helm_repo chart repository
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm_repo
|
name: test_helm_repo
|
||||||
state: absent
|
state: absent
|
||||||
register: repository
|
register: repository
|
||||||
@@ -51,6 +56,7 @@
|
|||||||
|
|
||||||
- name: Check idempotency after remove
|
- name: Check idempotency after remove
|
||||||
helm_repository:
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
name: test_helm_repo
|
name: test_helm_repo
|
||||||
state: absent
|
state: absent
|
||||||
register: repository
|
register: repository
|
||||||
2
tests/integration/targets/inventory_k8s/aliases
Normal file
2
tests/integration/targets/inventory_k8s/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
context/target
|
||||||
|
k8s
|
||||||
94
tests/integration/targets/inventory_k8s/playbooks/play.yml
Normal file
94
tests/integration/targets/inventory_k8s/playbooks/play.yml
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
collections:
|
||||||
|
- kubernetes.core
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- vars/main.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Ensure namespace exists
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: inventory
|
||||||
|
|
||||||
|
- name: Add a deployment
|
||||||
|
k8s:
|
||||||
|
definition:
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: inventory
|
||||||
|
namespace: inventory
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: "{{ k8s_pod_name }}"
|
||||||
|
template: "{{ k8s_pod_template }}"
|
||||||
|
wait: yes
|
||||||
|
wait_timeout: 240
|
||||||
|
vars:
|
||||||
|
k8s_pod_name: inventory
|
||||||
|
k8s_pod_image: python
|
||||||
|
k8s_pod_command:
|
||||||
|
- python
|
||||||
|
- '-m'
|
||||||
|
- http.server
|
||||||
|
k8s_pod_env:
|
||||||
|
- name: TEST
|
||||||
|
value: test
|
||||||
|
|
||||||
|
- meta: refresh_inventory
|
||||||
|
|
||||||
|
- name: Verify inventory and connection plugins
|
||||||
|
hosts: namespace_inventory_pods
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
vars:
|
||||||
|
file_content: |
|
||||||
|
Hello world
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: End play if host not running (TODO should we not add these to the inventory?)
|
||||||
|
meta: end_host
|
||||||
|
when: pod_phase != "Running"
|
||||||
|
|
||||||
|
- debug: var=hostvars
|
||||||
|
- setup:
|
||||||
|
|
||||||
|
- debug: var=ansible_facts
|
||||||
|
|
||||||
|
- name: Assert the TEST environment variable was retrieved
|
||||||
|
assert:
|
||||||
|
that: ansible_facts.env.TEST == 'test'
|
||||||
|
|
||||||
|
- name: Copy a file into the host
|
||||||
|
copy:
|
||||||
|
content: '{{ file_content }}'
|
||||||
|
dest: /tmp/test_file
|
||||||
|
|
||||||
|
- name: Retrieve the file from the host
|
||||||
|
slurp:
|
||||||
|
src: /tmp/test_file
|
||||||
|
register: slurped_file
|
||||||
|
|
||||||
|
- name: Assert the file content matches expectations
|
||||||
|
assert:
|
||||||
|
that: (slurped_file.content|b64decode) == file_content
|
||||||
|
|
||||||
|
- name: Delete inventory namespace
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- name: Remove inventory namespace
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: inventory
|
||||||
|
state: absent
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
export ANSIBLE_INVENTORY_ENABLED=kubernetes.core.k8s,yaml
|
||||||
|
export ANSIBLE_PYTHON_INTERPRETER=auto_silent
|
||||||
|
|
||||||
|
ansible-playbook playbooks/play.yml -i playbooks/test.inventory_k8s.yml "$@"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
plugin: kubernetes.core.k8s
|
||||||
2
tests/integration/targets/k8s_access_review/aliases
Normal file
2
tests/integration/targets/k8s_access_review/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
time=5
|
||||||
|
k8s
|
||||||
2
tests/integration/targets/k8s_append_hash/aliases
Normal file
2
tests/integration/targets/k8s_append_hash/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
time=6
|
||||||
|
k8s
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
4
tests/integration/targets/k8s_apply/aliases
Normal file
4
tests/integration/targets/k8s_apply/aliases
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
slow
|
||||||
|
k8s_service
|
||||||
|
k8s
|
||||||
|
time=192
|
||||||
40
tests/integration/targets/k8s_apply/defaults/main.yml
Normal file
40
tests/integration/targets/k8s_apply/defaults/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
k8s_pod_metadata:
|
||||||
|
labels:
|
||||||
|
app: "{{ k8s_pod_name }}"
|
||||||
|
|
||||||
|
k8s_pod_spec:
|
||||||
|
serviceAccount: "{{ k8s_pod_service_account }}"
|
||||||
|
containers:
|
||||||
|
- image: "{{ k8s_pod_image }}"
|
||||||
|
imagePullPolicy: Always
|
||||||
|
name: "{{ k8s_pod_name }}"
|
||||||
|
command: "{{ k8s_pod_command }}"
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/true
|
||||||
|
resources: "{{ k8s_pod_resources }}"
|
||||||
|
ports: "{{ k8s_pod_ports }}"
|
||||||
|
env: "{{ k8s_pod_env }}"
|
||||||
|
|
||||||
|
|
||||||
|
k8s_pod_service_account: default
|
||||||
|
|
||||||
|
k8s_pod_resources:
|
||||||
|
limits:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "100Mi"
|
||||||
|
|
||||||
|
k8s_pod_command: []
|
||||||
|
|
||||||
|
k8s_pod_ports: []
|
||||||
|
|
||||||
|
k8s_pod_env: []
|
||||||
|
|
||||||
|
k8s_pod_template:
|
||||||
|
metadata: "{{ k8s_pod_metadata }}"
|
||||||
|
spec: "{{ k8s_pod_spec }}"
|
||||||
|
|
||||||
|
k8s_wait_timeout: 240
|
||||||
@@ -307,6 +307,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
apply: yes
|
apply: yes
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: apply-deploy
|
k8s_pod_name: apply-deploy
|
||||||
@@ -378,6 +379,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
apply: yes
|
apply: yes
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: apply-deploy
|
k8s_pod_name: apply-deploy
|
||||||
@@ -426,6 +428,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
apply: yes
|
apply: yes
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: apply-deploy
|
k8s_pod_name: apply-deploy
|
||||||
@@ -449,318 +452,6 @@
|
|||||||
that:
|
that:
|
||||||
- deploy_after_serviceaccount_removal is failed
|
- deploy_after_serviceaccount_removal is failed
|
||||||
|
|
||||||
- name: Insert new service port
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: apply-svc
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: whatever
|
|
||||||
ports:
|
|
||||||
- name: mesh
|
|
||||||
port: 8080
|
|
||||||
targetPort: 8080
|
|
||||||
- name: http
|
|
||||||
port: 8081
|
|
||||||
targetPort: 8081
|
|
||||||
apply: yes
|
|
||||||
register: k8s_service_4
|
|
||||||
|
|
||||||
- name: Check ports are correct
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- k8s_service_4 is changed
|
|
||||||
- k8s_service_4.result.spec.ports | length == 2
|
|
||||||
- k8s_service_4.result.spec.ports[0].port == 8080
|
|
||||||
- k8s_service_4.result.spec.ports[1].port == 8081
|
|
||||||
|
|
||||||
- name: Remove new service port (check mode)
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: apply-svc
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: whatever
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8081
|
|
||||||
targetPort: 8081
|
|
||||||
apply: yes
|
|
||||||
check_mode: yes
|
|
||||||
register: k8s_service_check
|
|
||||||
|
|
||||||
- name: Check ports are correct
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- k8s_service_check is changed
|
|
||||||
- k8s_service_check.result.spec.ports | length == 1
|
|
||||||
- k8s_service_check.result.spec.ports[0].port == 8081
|
|
||||||
|
|
||||||
- name: Remove new service port
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: apply-svc
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: whatever
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8081
|
|
||||||
targetPort: 8081
|
|
||||||
apply: yes
|
|
||||||
register: k8s_service_5
|
|
||||||
|
|
||||||
- name: Check ports are correct
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- k8s_service_5 is changed
|
|
||||||
- k8s_service_5.result.spec.ports | length == 1
|
|
||||||
- k8s_service_5.result.spec.ports[0].port == 8081
|
|
||||||
|
|
||||||
- name: Add a serviceaccount
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
|
|
||||||
- name: Add a deployment
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: "{{ k8s_pod_name }}"
|
|
||||||
template: "{{ k8s_pod_template }}"
|
|
||||||
wait: yes
|
|
||||||
apply: yes
|
|
||||||
vars:
|
|
||||||
k8s_pod_name: apply-deploy
|
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green
|
|
||||||
k8s_pod_service_account: apply-deploy
|
|
||||||
k8s_pod_ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
name: http
|
|
||||||
protocol: TCP
|
|
||||||
|
|
||||||
- name: Remove the serviceaccount
|
|
||||||
k8s:
|
|
||||||
state: absent
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
|
|
||||||
- name: Update the earlier deployment
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
replicas: 2
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: "{{ k8s_pod_name }}"
|
|
||||||
template: "{{ k8s_pod_template }}"
|
|
||||||
wait: yes
|
|
||||||
apply: yes
|
|
||||||
vars:
|
|
||||||
k8s_pod_name: apply-deploy
|
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple
|
|
||||||
k8s_pod_service_account: apply-deploy
|
|
||||||
k8s_pod_ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
name: http
|
|
||||||
protocol: TCP
|
|
||||||
register: deploy_after_serviceaccount_removal
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: Ensure that updating deployment after service account removal failed
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- deploy_after_serviceaccount_removal is failed
|
|
||||||
|
|
||||||
- name: Insert new service port
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: apply-svc
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: whatever
|
|
||||||
ports:
|
|
||||||
- name: mesh
|
|
||||||
port: 8080
|
|
||||||
targetPort: 8080
|
|
||||||
- name: http
|
|
||||||
port: 8081
|
|
||||||
targetPort: 8081
|
|
||||||
apply: yes
|
|
||||||
register: k8s_service_4
|
|
||||||
|
|
||||||
- name: Check ports are correct
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- k8s_service_4 is changed
|
|
||||||
- k8s_service_4.result.spec.ports | length == 2
|
|
||||||
- k8s_service_4.result.spec.ports[0].port == 8080
|
|
||||||
- k8s_service_4.result.spec.ports[1].port == 8081
|
|
||||||
|
|
||||||
- name: Remove new service port (check mode)
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: apply-svc
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: whatever
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8081
|
|
||||||
targetPort: 8081
|
|
||||||
apply: yes
|
|
||||||
check_mode: yes
|
|
||||||
register: k8s_service_check
|
|
||||||
|
|
||||||
- name: Check ports are correct
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- k8s_service_check is changed
|
|
||||||
- k8s_service_check.result.spec.ports | length == 1
|
|
||||||
- k8s_service_check.result.spec.ports[0].port == 8081
|
|
||||||
|
|
||||||
- name: Remove new service port
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: apply-svc
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: whatever
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8081
|
|
||||||
targetPort: 8081
|
|
||||||
apply: yes
|
|
||||||
register: k8s_service_5
|
|
||||||
|
|
||||||
- name: Check ports are correct
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- k8s_service_5 is changed
|
|
||||||
- k8s_service_5.result.spec.ports | length == 1
|
|
||||||
- k8s_service_5.result.spec.ports[0].port == 8081
|
|
||||||
|
|
||||||
- name: Add a serviceaccount
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
|
|
||||||
- name: Add a deployment
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: "{{ k8s_pod_name }}"
|
|
||||||
template: "{{ k8s_pod_template }}"
|
|
||||||
wait: yes
|
|
||||||
apply: yes
|
|
||||||
vars:
|
|
||||||
k8s_pod_name: apply-deploy
|
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green
|
|
||||||
k8s_pod_service_account: apply-deploy
|
|
||||||
k8s_pod_ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
name: http
|
|
||||||
protocol: TCP
|
|
||||||
|
|
||||||
- name: Remove the serviceaccount
|
|
||||||
k8s:
|
|
||||||
state: absent
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
|
|
||||||
- name: Update the earlier deployment
|
|
||||||
k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: apply-deploy
|
|
||||||
namespace: "{{ apply_namespace }}"
|
|
||||||
spec:
|
|
||||||
replicas: 2
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: "{{ k8s_pod_name }}"
|
|
||||||
template: "{{ k8s_pod_template }}"
|
|
||||||
wait: yes
|
|
||||||
apply: yes
|
|
||||||
vars:
|
|
||||||
k8s_pod_name: apply-deploy
|
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple
|
|
||||||
k8s_pod_service_account: apply-deploy
|
|
||||||
k8s_pod_ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
name: http
|
|
||||||
protocol: TCP
|
|
||||||
register: deploy_after_serviceaccount_removal
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: Ensure that updating deployment after service account removal failed
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- deploy_after_serviceaccount_removal is failed
|
|
||||||
|
|
||||||
- name: Add a secret
|
- name: Add a secret
|
||||||
k8s:
|
k8s:
|
||||||
definition:
|
definition:
|
||||||
2
tests/integration/targets/k8s_cluster_info/aliases
Normal file
2
tests/integration/targets/k8s_cluster_info/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
k8s_cluster_info
|
||||||
|
time=6
|
||||||
2
tests/integration/targets/k8s_crd/aliases
Normal file
2
tests/integration/targets/k8s_crd/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
k8s
|
||||||
|
time=15
|
||||||
1
tests/integration/targets/k8s_crd/defaults/main.yml
Normal file
1
tests/integration/targets/k8s_crd/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
- name: Install custom resource definitions
|
- name: Install custom resource definitions
|
||||||
k8s:
|
k8s:
|
||||||
definition: "{{ lookup('file', kubernetes_role_path + '/files/setup-crd.yml') }}"
|
definition: "{{ lookup('file', 'setup-crd.yml') }}"
|
||||||
|
|
||||||
- name: Pause 5 seconds to avoid race condition
|
- name: Pause 5 seconds to avoid race condition
|
||||||
pause:
|
pause:
|
||||||
@@ -15,14 +15,14 @@
|
|||||||
|
|
||||||
- name: Create custom resource definition
|
- name: Create custom resource definition
|
||||||
k8s:
|
k8s:
|
||||||
definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
|
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||||
namespace: crd
|
namespace: crd
|
||||||
apply: "{{ create_crd_with_apply | default(omit) }}"
|
apply: "{{ create_crd_with_apply | default(omit) }}"
|
||||||
register: create_crd
|
register: create_crd
|
||||||
|
|
||||||
- name: Patch custom resource definition
|
- name: Patch custom resource definition
|
||||||
k8s:
|
k8s:
|
||||||
definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
|
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||||
namespace: crd
|
namespace: crd
|
||||||
register: recreate_crd
|
register: recreate_crd
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
- block:
|
- block:
|
||||||
- name: Recreate custom resource definition with merge_type
|
- name: Recreate custom resource definition with merge_type
|
||||||
k8s:
|
k8s:
|
||||||
definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
|
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||||
merge_type:
|
merge_type:
|
||||||
- merge
|
- merge
|
||||||
namespace: crd
|
namespace: crd
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
- name: Recreate custom resource definition with merge_type list
|
- name: Recreate custom resource definition with merge_type list
|
||||||
k8s:
|
k8s:
|
||||||
definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
|
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||||
merge_type:
|
merge_type:
|
||||||
- strategic-merge
|
- strategic-merge
|
||||||
- merge
|
- merge
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
- name: Remove crd
|
- name: Remove crd
|
||||||
k8s:
|
k8s:
|
||||||
definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
|
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||||
namespace: crd
|
namespace: crd
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
3
tests/integration/targets/k8s_delete/aliases
Normal file
3
tests/integration/targets/k8s_delete/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
k8s_info
|
||||||
|
k8s
|
||||||
|
time=64
|
||||||
40
tests/integration/targets/k8s_delete/defaults/main.yml
Normal file
40
tests/integration/targets/k8s_delete/defaults/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
k8s_pod_metadata:
|
||||||
|
labels:
|
||||||
|
app: "{{ k8s_pod_name }}"
|
||||||
|
|
||||||
|
k8s_pod_spec:
|
||||||
|
serviceAccount: "{{ k8s_pod_service_account }}"
|
||||||
|
containers:
|
||||||
|
- image: "{{ k8s_pod_image }}"
|
||||||
|
imagePullPolicy: Always
|
||||||
|
name: "{{ k8s_pod_name }}"
|
||||||
|
command: "{{ k8s_pod_command }}"
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/true
|
||||||
|
resources: "{{ k8s_pod_resources }}"
|
||||||
|
ports: "{{ k8s_pod_ports }}"
|
||||||
|
env: "{{ k8s_pod_env }}"
|
||||||
|
|
||||||
|
|
||||||
|
k8s_pod_service_account: default
|
||||||
|
|
||||||
|
k8s_pod_resources:
|
||||||
|
limits:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "100Mi"
|
||||||
|
|
||||||
|
k8s_pod_command: []
|
||||||
|
|
||||||
|
k8s_pod_ports: []
|
||||||
|
|
||||||
|
k8s_pod_env: []
|
||||||
|
|
||||||
|
k8s_pod_template:
|
||||||
|
metadata: "{{ k8s_pod_metadata }}"
|
||||||
|
spec: "{{ k8s_pod_spec }}"
|
||||||
|
|
||||||
|
kubernetes_role_path: ../../tests/integration/targets/kubernetes
|
||||||
3
tests/integration/targets/k8s_exec/aliases
Normal file
3
tests/integration/targets/k8s_exec/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
k8s_exec
|
||||||
|
k8s
|
||||||
|
time=11
|
||||||
1
tests/integration/targets/k8s_exec/defaults/main.yml
Normal file
1
tests/integration/targets/k8s_exec/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
3
tests/integration/targets/k8s_full/aliases
Normal file
3
tests/integration/targets/k8s_full/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
|
time=37
|
||||||
1
tests/integration/targets/k8s_full/defaults/main.yml
Normal file
1
tests/integration/targets/k8s_full/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
2
tests/integration/targets/k8s_gc/aliases
Normal file
2
tests/integration/targets/k8s_gc/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
k8s
|
||||||
|
time=142
|
||||||
1
tests/integration/targets/k8s_gc/defaults/main.yml
Normal file
1
tests/integration/targets/k8s_gc/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
3
tests/integration/targets/k8s_info/aliases
Normal file
3
tests/integration/targets/k8s_info/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
|
time=13
|
||||||
3
tests/integration/targets/k8s_json_patch/aliases
Normal file
3
tests/integration/targets/k8s_json_patch/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
k8s_json_patch
|
||||||
|
k8s
|
||||||
|
time=33
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace: json-patch
|
namespace: json-patch
|
||||||
pod: json-patch
|
pod: json-patch
|
||||||
deployment: json-patch
|
deployment: json-patch
|
||||||
|
k8s_wait_timeout: 240
|
||||||
|
|
||||||
block:
|
block:
|
||||||
- name: Ensure namespace exists
|
- name: Ensure namespace exists
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
- -c
|
- -c
|
||||||
- while true; do echo $(date); sleep 10; done
|
- while true; do echo $(date); sleep 10; done
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
|
|
||||||
- name: Add a label and replace the image in checkmode
|
- name: Add a label and replace the image in checkmode
|
||||||
kubernetes.core.k8s_json_patch:
|
kubernetes.core.k8s_json_patch:
|
||||||
@@ -118,6 +120,7 @@
|
|||||||
- name: Create a simple deployment
|
- name: Create a simple deployment
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
definition:
|
definition:
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -154,6 +157,7 @@
|
|||||||
path: /spec/replicas
|
path: /spec/replicas
|
||||||
value: 3
|
value: 3
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert all replicas are available
|
- name: Assert all replicas are available
|
||||||
3
tests/integration/targets/k8s_lists/aliases
Normal file
3
tests/integration/targets/k8s_lists/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
k8s_info
|
||||||
|
k8s
|
||||||
|
time=22
|
||||||
2
tests/integration/targets/k8s_log/aliases
Normal file
2
tests/integration/targets/k8s_log/aliases
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
k8s_log
|
||||||
|
time=27
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
|
- set_fact:
|
||||||
|
k8s_wait_timeout: 240
|
||||||
|
|
||||||
- name: ensure that k8s-log namespace exists
|
- name: ensure that k8s-log namespace exists
|
||||||
k8s:
|
k8s:
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -8,6 +11,7 @@
|
|||||||
- name: create hello-world deployment
|
- name: create hello-world deployment
|
||||||
k8s:
|
k8s:
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
definition:
|
definition:
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
3
tests/integration/targets/k8s_merge_type/aliases
Normal file
3
tests/integration/targets/k8s_merge_type/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
time=19
|
||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
3
tests/integration/targets/k8s_patched/aliases
Normal file
3
tests/integration/targets/k8s_patched/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
time=20
|
||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
4
tests/integration/targets/k8s_rollback/aliases
Normal file
4
tests/integration/targets/k8s_rollback/aliases
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
k8s_rollback
|
||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
|
time=187
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
- name: Set variables
|
- name: Set variables
|
||||||
set_fact:
|
set_fact:
|
||||||
namespace: "testingrollback"
|
namespace: "testingrollback"
|
||||||
|
k8s_wait_timeout: 240
|
||||||
|
|
||||||
- name: Create a namespace
|
- name: Create a namespace
|
||||||
k8s:
|
k8s:
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
inline: &deploy
|
inline: &deploy
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -53,6 +55,7 @@
|
|||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
definition:
|
definition:
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -96,6 +99,7 @@
|
|||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
definition:
|
definition:
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: DaemonSet
|
kind: DaemonSet
|
||||||
@@ -149,6 +153,7 @@
|
|||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
definition:
|
definition:
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: DaemonSet
|
kind: DaemonSet
|
||||||
4
tests/integration/targets/k8s_scale/aliases
Normal file
4
tests/integration/targets/k8s_scale/aliases
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
k8s_scale
|
||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
|
time=150
|
||||||
40
tests/integration/targets/k8s_scale/defaults/main.yml
Normal file
40
tests/integration/targets/k8s_scale/defaults/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
k8s_pod_metadata:
|
||||||
|
labels:
|
||||||
|
app: "{{ k8s_pod_name }}"
|
||||||
|
|
||||||
|
k8s_pod_spec:
|
||||||
|
serviceAccount: "{{ k8s_pod_service_account }}"
|
||||||
|
containers:
|
||||||
|
- image: "{{ k8s_pod_image }}"
|
||||||
|
imagePullPolicy: Always
|
||||||
|
name: "{{ k8s_pod_name }}"
|
||||||
|
command: "{{ k8s_pod_command }}"
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/true
|
||||||
|
resources: "{{ k8s_pod_resources }}"
|
||||||
|
ports: "{{ k8s_pod_ports }}"
|
||||||
|
env: "{{ k8s_pod_env }}"
|
||||||
|
|
||||||
|
|
||||||
|
k8s_pod_service_account: default
|
||||||
|
|
||||||
|
k8s_pod_resources:
|
||||||
|
limits:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "100Mi"
|
||||||
|
|
||||||
|
k8s_pod_command: []
|
||||||
|
|
||||||
|
k8s_pod_ports: []
|
||||||
|
|
||||||
|
k8s_pod_env: []
|
||||||
|
|
||||||
|
k8s_pod_template:
|
||||||
|
metadata: "{{ k8s_pod_metadata }}"
|
||||||
|
spec: "{{ k8s_pod_spec }}"
|
||||||
|
|
||||||
|
k8s_wait_timeout: 400
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
wait_timeout: 60
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
apply: yes
|
apply: yes
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: scale-deploy
|
k8s_pod_name: scale-deploy
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
namespace: "{{ scale_namespace }}"
|
namespace: "{{ scale_namespace }}"
|
||||||
replicas: 0
|
replicas: 0
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: scale_down
|
register: scale_down
|
||||||
|
|
||||||
- name: Get pods in scale-deploy
|
- name: Get pods in scale-deploy
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
wait_timeout: 60
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
apply: yes
|
apply: yes
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: scale-deploy
|
k8s_pod_name: scale-deploy
|
||||||
@@ -125,7 +126,7 @@
|
|||||||
namespace: "{{ scale_namespace }}"
|
namespace: "{{ scale_namespace }}"
|
||||||
replicas: 2
|
replicas: 2
|
||||||
wait: yes
|
wait: yes
|
||||||
wait_timeout: 60
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: scale_up
|
register: scale_up
|
||||||
|
|
||||||
- name: Get pods in scale-deploy
|
- name: Get pods in scale-deploy
|
||||||
@@ -154,6 +155,7 @@
|
|||||||
namespace: "{{ scale_namespace }}"
|
namespace: "{{ scale_namespace }}"
|
||||||
replicas: 2
|
replicas: 2
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: scale_up_noop
|
register: scale_up_noop
|
||||||
|
|
||||||
- name: Get pods in scale-deploy
|
- name: Get pods in scale-deploy
|
||||||
@@ -227,6 +229,8 @@
|
|||||||
resource_version: 0
|
resource_version: 0
|
||||||
label_selectors:
|
label_selectors:
|
||||||
- app=nginx
|
- app=nginx
|
||||||
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: scale_out
|
register: scale_out
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -257,6 +261,8 @@
|
|||||||
namespace: "{{ scale_namespace }}"
|
namespace: "{{ scale_namespace }}"
|
||||||
label_selectors:
|
label_selectors:
|
||||||
- app=nginx
|
- app=nginx
|
||||||
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: scale_out
|
register: scale_out
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
4
tests/integration/targets/k8s_template/aliases
Normal file
4
tests/integration/targets/k8s_template/aliases
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
k8s_service
|
||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
|
time=75
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
- block:
|
- block:
|
||||||
- set_fact:
|
- set_fact:
|
||||||
template_namespace: template-test
|
template_namespace: template-test
|
||||||
|
k8s_wait_timeout: 240
|
||||||
|
|
||||||
- name: Ensure namespace exists
|
- name: Ensure namespace exists
|
||||||
k8s:
|
k8s:
|
||||||
@@ -72,6 +73,7 @@
|
|||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
template: "pod_template_one.j2"
|
template: "pod_template_one.j2"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name_one: pod-1
|
k8s_pod_name_one: pod-1
|
||||||
k8s_pod_namespace: "{{ template_namespace }}"
|
k8s_pod_namespace: "{{ template_namespace }}"
|
||||||
@@ -103,6 +105,7 @@
|
|||||||
template:
|
template:
|
||||||
path: "pod_template_one.j2"
|
path: "pod_template_one.j2"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name_one: pod-3
|
k8s_pod_name_one: pod-3
|
||||||
k8s_pod_namespace: "{{ template_namespace }}"
|
k8s_pod_namespace: "{{ template_namespace }}"
|
||||||
@@ -120,6 +123,7 @@
|
|||||||
variable_start_string: '[['
|
variable_start_string: '[['
|
||||||
variable_end_string: ']]'
|
variable_end_string: ']]'
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name_two: pod-4
|
k8s_pod_name_two: pod-4
|
||||||
k8s_pod_namespace: "[[ template_namespace ]]"
|
k8s_pod_namespace: "[[ template_namespace ]]"
|
||||||
@@ -136,6 +140,7 @@
|
|||||||
template:
|
template:
|
||||||
path: "pod_template_three.j2"
|
path: "pod_template_three.j2"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name_three_one: pod-5
|
k8s_pod_name_three_one: pod-5
|
||||||
k8s_pod_name_three_two: pod-6
|
k8s_pod_name_three_two: pod-6
|
||||||
@@ -156,6 +161,7 @@
|
|||||||
variable_end_string: ']]'
|
variable_end_string: ']]'
|
||||||
- path: "pod_template_three.j2"
|
- path: "pod_template_three.j2"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name_one: pod-7
|
k8s_pod_name_one: pod-7
|
||||||
k8s_pod_name_two: pod-8
|
k8s_pod_name_two: pod-8
|
||||||
@@ -224,6 +230,7 @@
|
|||||||
- pod_template_one.j2
|
- pod_template_one.j2
|
||||||
continue_on_error: true
|
continue_on_error: true
|
||||||
wait: true
|
wait: true
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
register: resource
|
register: resource
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
@@ -239,17 +246,6 @@
|
|||||||
- resource.result.results | selectattr('changed') | list | length == 1
|
- resource.result.results | selectattr('changed') | list | length == 1
|
||||||
- resource.result.results | selectattr('error', 'defined') | list | length == 1
|
- resource.result.results | selectattr('error', 'defined') | list | length == 1
|
||||||
|
|
||||||
- name: Remove Pod (Cleanup)
|
|
||||||
kubernetes.core.k8s:
|
|
||||||
api_version: v1
|
|
||||||
kind: Pod
|
|
||||||
name: "pod-{{ item }}"
|
|
||||||
namespace: "{{ template_namespace }}"
|
|
||||||
state: absent
|
|
||||||
wait: yes
|
|
||||||
ignore_errors: yes
|
|
||||||
loop: "{{ range(1, 12) | list }}"
|
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Remove namespace (Cleanup)
|
- name: Remove namespace (Cleanup)
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
5
tests/integration/targets/k8s_waiter/aliases
Normal file
5
tests/integration/targets/k8s_waiter/aliases
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# duration 10min
|
||||||
|
slow
|
||||||
|
time=504
|
||||||
|
k8s
|
||||||
|
k8s_info
|
||||||
40
tests/integration/targets/k8s_waiter/defaults/main.yml
Normal file
40
tests/integration/targets/k8s_waiter/defaults/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
k8s_pod_metadata:
|
||||||
|
labels:
|
||||||
|
app: "{{ k8s_pod_name }}"
|
||||||
|
|
||||||
|
k8s_pod_spec:
|
||||||
|
serviceAccount: "{{ k8s_pod_service_account }}"
|
||||||
|
containers:
|
||||||
|
- image: "{{ k8s_pod_image }}"
|
||||||
|
imagePullPolicy: Always
|
||||||
|
name: "{{ k8s_pod_name }}"
|
||||||
|
command: "{{ k8s_pod_command }}"
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/true
|
||||||
|
resources: "{{ k8s_pod_resources }}"
|
||||||
|
ports: "{{ k8s_pod_ports }}"
|
||||||
|
env: "{{ k8s_pod_env }}"
|
||||||
|
|
||||||
|
|
||||||
|
k8s_pod_service_account: default
|
||||||
|
|
||||||
|
k8s_pod_resources:
|
||||||
|
limits:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "100Mi"
|
||||||
|
|
||||||
|
k8s_pod_command: []
|
||||||
|
|
||||||
|
k8s_pod_ports: []
|
||||||
|
|
||||||
|
k8s_pod_env: []
|
||||||
|
|
||||||
|
k8s_pod_template:
|
||||||
|
metadata: "{{ k8s_pod_metadata }}"
|
||||||
|
spec: "{{ k8s_pod_spec }}"
|
||||||
|
|
||||||
|
k8s_wait_timeout: 240
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
namespace: "{{ wait_namespace }}"
|
namespace: "{{ wait_namespace }}"
|
||||||
spec: "{{ k8s_pod_spec }}"
|
spec: "{{ k8s_pod_spec }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: wait-pod
|
k8s_pod_name: wait-pod
|
||||||
k8s_pod_image: alpine:3.8
|
k8s_pod_image: alpine:3.8
|
||||||
@@ -49,8 +50,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
wait_sleep: 5
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
wait_timeout: 180
|
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: wait-ds
|
k8s_pod_name: wait-ds
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
wait_sleep: 3
|
wait_sleep: 3
|
||||||
wait_timeout: 180
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: wait-ds
|
k8s_pod_name: wait-ds
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
wait_sleep: 3
|
wait_sleep: 3
|
||||||
wait_timeout: 180
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: wait-ds
|
k8s_pod_name: wait-ds
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3
|
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3
|
||||||
@@ -203,6 +203,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: wait-deploy
|
k8s_pod_name: wait-deploy
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
||||||
@@ -233,6 +234,7 @@
|
|||||||
app: "{{ k8s_pod_name }}"
|
app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
vars:
|
vars:
|
||||||
k8s_pod_name: wait-deploy
|
k8s_pod_name: wait-deploy
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
||||||
@@ -279,6 +281,7 @@
|
|||||||
paused: True
|
paused: True
|
||||||
apply: no
|
apply: no
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
|
||||||
wait_condition:
|
wait_condition:
|
||||||
type: Progressing
|
type: Progressing
|
||||||
status: Unknown
|
status: Unknown
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
Wait tests
|
|
||||||
----------
|
|
||||||
|
|
||||||
wait tests require at least one node, and don't work on the normal k8s
|
|
||||||
openshift-origin container as provided by ansible-test --docker -v k8s
|
|
||||||
|
|
||||||
minikube, Kubernetes from Docker or any other Kubernetes service will
|
|
||||||
suffice.
|
|
||||||
|
|
||||||
If kubectl is already using the right config file and context, you can
|
|
||||||
just do
|
|
||||||
|
|
||||||
```
|
|
||||||
cd tests/integration/targets/k8s
|
|
||||||
./runme.sh -vv
|
|
||||||
```
|
|
||||||
|
|
||||||
otherwise set one or both of `K8S_AUTH_KUBECONFIG` and `K8S_AUTH_CONTEXT`
|
|
||||||
and use the same command
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
cloud/openshift
|
|
||||||
shippable/cloud/group1
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: kuard
|
|
||||||
name: kuard
|
|
||||||
namespace: default
|
|
||||||
spec:
|
|
||||||
replicas: 3
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: kuard
|
|
||||||
unwanted: value
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: kuard
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- image: gcr.io/kuar-demo/kuard-amd64:1
|
|
||||||
name: kuard
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: kuard
|
|
||||||
name: kuard
|
|
||||||
namespace: default
|
|
||||||
spec:
|
|
||||||
replicas: hello
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: kuard
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: kuard
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- image: gcr.io/kuar-demo/kuard-amd64:1
|
|
||||||
name: kuard
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
- name: delete temporary directory
|
|
||||||
file:
|
|
||||||
path: "{{ remote_tmp_dir }}"
|
|
||||||
state: absent
|
|
||||||
no_log: yes
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# README
|
|
||||||
|
|
||||||
The `test_tempfile.py` module added here is only used for the `setup_remote_tmp_dir.yml` temporary directory setup task. It is a clone of the `tempfile.py` community-supported Ansible module, and has to be included with the tests here because it is not available in the `ansible-base` distribution against which this collection is tested.
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright: (c) 2016, Krzysztof Magosa <krzysztof@magosa.pl>
|
|
||||||
# Copyright: (c) 2017, Ansible Project
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: test_tempfile
|
|
||||||
|
|
||||||
short_description: Creates temporary files and directories
|
|
||||||
|
|
||||||
description:
|
|
||||||
- The C(test_tempfile) module creates temporary files and directories. C(mktemp) command takes different parameters on various systems, this module helps
|
|
||||||
to avoid troubles related to that. Files/directories created by module are accessible only by creator. In case you need to make them world-accessible
|
|
||||||
you need to use M(ansible.builtin.file) module.
|
|
||||||
- For Windows targets, use the M(ansible.builtin.win_tempfile) module instead.
|
|
||||||
|
|
||||||
options:
|
|
||||||
state:
|
|
||||||
description:
|
|
||||||
- Whether to create file or directory.
|
|
||||||
type: str
|
|
||||||
choices: [ directory, file ]
|
|
||||||
default: file
|
|
||||||
path:
|
|
||||||
description:
|
|
||||||
- Location where temporary file or directory should be created.
|
|
||||||
- If path is not specified, the default system temporary directory will be used.
|
|
||||||
type: path
|
|
||||||
prefix:
|
|
||||||
description:
|
|
||||||
- Prefix of file/directory name created by module.
|
|
||||||
type: str
|
|
||||||
default: ansible.
|
|
||||||
suffix:
|
|
||||||
description:
|
|
||||||
- Suffix of file/directory name created by module.
|
|
||||||
type: str
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
seealso:
|
|
||||||
- module: file
|
|
||||||
- module: win_tempfile
|
|
||||||
|
|
||||||
author:
|
|
||||||
- Krzysztof Magosa (@krzysztof-magosa)
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
- name: create temporary build directory
|
|
||||||
test_tempfile:
|
|
||||||
state: directory
|
|
||||||
suffix: build
|
|
||||||
|
|
||||||
- name: create temporary file
|
|
||||||
test_tempfile:
|
|
||||||
state: file
|
|
||||||
suffix: temp
|
|
||||||
register: tempfile_1
|
|
||||||
|
|
||||||
- name: use the registered var and the file module to remove the temporary file
|
|
||||||
file:
|
|
||||||
path: "{{ tempfile_1.path }}"
|
|
||||||
state: absent
|
|
||||||
when: tempfile_1.path is defined
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
path:
|
|
||||||
description: Path to created file or directory
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "/tmp/ansible.bMlvdk"
|
|
||||||
'''
|
|
||||||
|
|
||||||
from os import close
|
|
||||||
from tempfile import mkstemp, mkdtemp
|
|
||||||
from traceback import format_exc
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
module = AnsibleModule(
|
|
||||||
argument_spec=dict(
|
|
||||||
state=dict(type='str', default='file', choices=['file', 'directory']),
|
|
||||||
path=dict(type='path'),
|
|
||||||
prefix=dict(type='str', default='ansible.'),
|
|
||||||
suffix=dict(type='str', default=''),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
if module.params['state'] == 'file':
|
|
||||||
handle, path = mkstemp(
|
|
||||||
prefix=module.params['prefix'],
|
|
||||||
suffix=module.params['suffix'],
|
|
||||||
dir=module.params['path'],
|
|
||||||
)
|
|
||||||
close(handle)
|
|
||||||
elif module.params['state'] == 'directory':
|
|
||||||
path = mkdtemp(
|
|
||||||
prefix=module.params['prefix'],
|
|
||||||
suffix=module.params['suffix'],
|
|
||||||
dir=module.params['path'],
|
|
||||||
)
|
|
||||||
|
|
||||||
module.exit_json(changed=True, path=path)
|
|
||||||
except Exception as e:
|
|
||||||
module.fail_json(msg=to_native(e), exception=format_exc())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
dependencies: []
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
---
|
|
||||||
- include_tasks: setup_remote_tmp_dir.yml
|
|
||||||
|
|
||||||
- set_fact:
|
|
||||||
virtualenv: "{{ remote_tmp_dir }}/virtualenv"
|
|
||||||
virtualenv_command: "{{ ansible_python_interpreter }} -m venv"
|
|
||||||
|
|
||||||
- set_fact:
|
|
||||||
virtualenv_interpreter: "{{ virtualenv }}/bin/python"
|
|
||||||
|
|
||||||
# Test graceful failure for missing kubernetes-validate
|
|
||||||
|
|
||||||
- pip:
|
|
||||||
name:
|
|
||||||
- kubernetes>=12.0.0
|
|
||||||
- coverage>=5.3
|
|
||||||
virtualenv: "{{ virtualenv }}"
|
|
||||||
virtualenv_command: "{{ virtualenv_command }}"
|
|
||||||
virtualenv_site_packages: no
|
|
||||||
|
|
||||||
- include_tasks: validate_not_installed.yml
|
|
||||||
vars:
|
|
||||||
ansible_python_interpreter: "{{ virtualenv_interpreter }}"
|
|
||||||
|
|
||||||
- file:
|
|
||||||
path: "{{ virtualenv }}"
|
|
||||||
state: absent
|
|
||||||
no_log: yes
|
|
||||||
|
|
||||||
# Test validate with kubernetes-validate
|
|
||||||
|
|
||||||
- pip:
|
|
||||||
name:
|
|
||||||
- kubernetes-validate==1.12.0
|
|
||||||
- kubernetes>=12.0.0
|
|
||||||
- coverage>=5.3
|
|
||||||
virtualenv: "{{ virtualenv }}"
|
|
||||||
virtualenv_command: "{{ virtualenv_command }}"
|
|
||||||
virtualenv_site_packages: no
|
|
||||||
|
|
||||||
- include_tasks: validate_installed.yml
|
|
||||||
vars:
|
|
||||||
ansible_python_interpreter: "{{ virtualenv_interpreter }}"
|
|
||||||
playbook_namespace: ansible-test-k8s-validate
|
|
||||||
|
|
||||||
- file:
|
|
||||||
path: "{{ virtualenv }}"
|
|
||||||
state: absent
|
|
||||||
no_log: yes
|
|
||||||
|
|
||||||
# Test new config getter (kubernetes==12.0.0)
|
|
||||||
|
|
||||||
- pip:
|
|
||||||
name:
|
|
||||||
- kubernetes==12.0.0
|
|
||||||
- coverage>=5.3
|
|
||||||
virtualenv: "{{ virtualenv }}"
|
|
||||||
virtualenv_command: "{{ virtualenv_command }}"
|
|
||||||
virtualenv_site_packages: no
|
|
||||||
|
|
||||||
- pip:
|
|
||||||
name:
|
|
||||||
- kubernetes>=12.0.0
|
|
||||||
virtualenv: "{{ virtualenv }}"
|
|
||||||
virtualenv_command: "{{ virtualenv_command }}"
|
|
||||||
virtualenv_site_packages: no
|
|
||||||
|
|
||||||
- include_tasks: new_config_getter.yml
|
|
||||||
vars:
|
|
||||||
ansible_python_interpreter: "{{ virtualenv_interpreter }}"
|
|
||||||
playbook_namespace: ansible-test-k8s-config-getter
|
|
||||||
|
|
||||||
- file:
|
|
||||||
path: "{{ virtualenv }}"
|
|
||||||
state: absent
|
|
||||||
no_log: yes
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user