|
27 | 27 |
|
28 | 28 | # Kubeconfig path - use user-provided or default to CRC location |
29 | 29 | kubeconfig_path: "{{ cifmw_openshift_kubeconfig | default(ansible_env.HOME ~ '/.crc/machines/crc/kubeconfig') }}" |
| 30 | + |
| 31 | + # test-operator assigns every test pod a dedicated ServiceAccount named |
| 32 | + # "<CRD name>-<CR instance name>" (e.g., the "ansibletest-ansibletest-lightspeed" |
| 33 | + # SA for an AnsibleTest CR named "ansibletest-lightspeed"). The ci-framework |
| 34 | + # test_operator role names the AnsibleTest CR as follows: |
| 35 | + # |
| 36 | + # "<cifmw_test_operator_ansibletest_name>-<cifmw_test_operator_stages[*].name>". |
| 37 | + # |
| 38 | + # The current default value of openstack_lightspeed_ansibletest_service_account ensures |
| 39 | + # that we mount the necessary lightspeed permissions (get /ls-access) to the correct SA used |
| 40 | + # by test-operator. Note that this works only when there is a single ansibletest step in |
| 41 | + # cifmw_test_operator_stages. If more steps are introduced, this needs to be updated |
| 42 | + # appropriately. |
| 43 | + openstack_lightspeed_ansibletest_stage: >- |
| 44 | + {{ |
| 45 | + cifmw_test_operator_stages | default([]) |
| 46 | + | selectattr('type', 'equalto', 'ansibletest') |
| 47 | + | map(attribute='name') | first | default('lightspeed') |
| 48 | + }} |
| 49 | + openstack_lightspeed_ansibletest_service_account: >- |
| 50 | + ansibletest-{{ cifmw_test_operator_ansibletest_name | default('ansibletest') }}-{{ openstack_lightspeed_ansibletest_stage }} |
30 | 51 | environment: |
31 | 52 | KUBECONFIG: "{{ kubeconfig_path }}" |
32 | 53 |
|
|
468 | 489 | kind: ClusterRole |
469 | 490 | name: lightspeed-access |
470 | 491 | subjects: |
471 | | - # The current test-operator uses the namespace's default account. |
| 492 | + # The dedicated ServiceAccount that test-operator runs the |
| 493 | + # test Pod under (see openstack_lightspeed_ansibletest_service_account). |
| 494 | + - kind: ServiceAccount |
| 495 | + name: "{{ openstack_lightspeed_ansibletest_service_account }}" |
| 496 | + namespace: "{{ cifmw_test_operator_namespace | default('openstack') }}" |
| 497 | + |
| 498 | + # The OpenStack Assistant e2e test from lightspeed-tests execs into |
| 499 | + # the openstack-assistant Pod (goose acp) over pods/exec. The request |
| 500 | + # is authorized as the test Pod's ServiceAccount, which needs both: |
| 501 | + # |
| 502 | + # 1. create/get on the pods/exec subresource (plus get/list on pods) |
| 503 | + # in the namespace where the assistant Pod runs; |
| 504 | + # 2. "use" of the SCC that admitted the assistant Pod (nonroot-v2). |
| 505 | + # |
| 506 | + # (2) is already granted to the ServiceAccount by test-operator itself, |
| 507 | + # so only (1) needs to be bound here. Note that during exec OpenShift |
| 508 | + # revalidates the target Pod's security context against the SCCs |
| 509 | + # available to the caller, which is why (2) matters at all. |
| 510 | + - name: Authorize the test Pod to exec into the OpenStack Assistant |
| 511 | + when: openstack_assistant_enabled | default(false) | bool |
| 512 | + kubernetes.core.k8s: |
| 513 | + state: present |
| 514 | + definition: |
| 515 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 516 | + kind: ClusterRole |
| 517 | + metadata: |
| 518 | + name: lightspeed-tests-assistant-exec |
| 519 | + rules: |
| 520 | + - apiGroups: [""] |
| 521 | + resources: ["pods"] |
| 522 | + verbs: ["get", "list"] |
| 523 | + - apiGroups: [""] |
| 524 | + resources: ["pods/exec"] |
| 525 | + verbs: ["create", "get"] |
| 526 | + |
| 527 | + - name: Bind the exec permissions to the test-operator ServiceAccount |
| 528 | + when: openstack_assistant_enabled | default(false) | bool |
| 529 | + kubernetes.core.k8s: |
| 530 | + state: present |
| 531 | + definition: |
| 532 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 533 | + kind: RoleBinding |
| 534 | + metadata: |
| 535 | + name: lightspeed-tests-assistant-exec |
| 536 | + namespace: "{{ cifmw_test_operator_namespace | default('openstack') }}" |
| 537 | + roleRef: |
| 538 | + apiGroup: rbac.authorization.k8s.io |
| 539 | + kind: ClusterRole |
| 540 | + name: lightspeed-tests-assistant-exec |
| 541 | + subjects: |
472 | 542 | - kind: ServiceAccount |
473 | | - name: default |
| 543 | + name: "{{ openstack_lightspeed_ansibletest_service_account }}" |
474 | 544 | namespace: "{{ cifmw_test_operator_namespace | default('openstack') }}" |
475 | 545 |
|
476 | 546 | - name: Create test-operator dummy config ConfigMap |
|
0 commit comments