Skip to content

Commit

Permalink
tests/k8s_user_impersonation: adjustement for k8s 1.24 (#520)
Browse files Browse the repository at this point in the history
tests/k8s_user_impersonation: adjustement for k8s 1.24

In Kubernetes 1.24, ServiceAccount token secrets are no longer automatically generated.
See: KEP-2799

Reviewed-by: Bikouo Aubin <None>
  • Loading branch information
goneri authored Sep 28, 2022
1 parent 454d0ef commit 093d06a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/k8s_user_impersonation_k8s_1_24.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "Adjust k8s_user_impersonation tests to be compatible with Kubernetes 1.24 (https://github.com/ansible-collections/kubernetes.core/pull/520)."
21 changes: 18 additions & 3 deletions tests/integration/targets/k8s_user_impersonation/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@
- "{{ user_01 }}"
- "{{ user_02 }}"

- name: Create Service token
kubernetes.core.k8s:
definition:
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
name: "{{ item }}"
annotations:
kubernetes.io/service-account.name: "{{ item }}"
namespace: "{{ test_ns }}"
with_items:
- "{{ user_01 }}"
- "{{ user_02 }}"

- name: Read Service Account - user_01
kubernetes.core.k8s_info:
kind: ServiceAccount
Expand All @@ -38,7 +53,7 @@
kubernetes.core.k8s_info:
kind: Secret
namespace: '{{ test_ns }}'
name: '{{ result.resources[0].secrets[0].name }}'
name: '{{ user_01 }}'
no_log: true
register: _secret

Expand All @@ -47,7 +62,7 @@

- name: Read Service Account - user_02
kubernetes.core.k8s_info:
kind: ServiceAccount
kind: Secret
namespace: "{{ test_ns }}"
name: "{{ user_02 }}"
register: result
Expand All @@ -56,7 +71,7 @@
kubernetes.core.k8s_info:
kind: Secret
namespace: '{{ test_ns }}'
name: '{{ result.resources[0].secrets[0].name }}'
name: '{{ user_02 }}'
no_log: true
register: _secret

Expand Down

0 comments on commit 093d06a

Please sign in to comment.