Skip to content

Commit

Permalink
tests/k8s_user_impersonation: adjustement for k8s 1.24
Browse files Browse the repository at this point in the history
In Kubernetes 1.24, ServiceAccount token secrets are no longer automatically generated.

See: KEP-2799
  • Loading branch information
goneri committed Sep 26, 2022
1 parent 08596fd commit 77c9ca1
Showing 1 changed file with 18 additions and 3 deletions.
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 77c9ca1

Please sign in to comment.