Free RedHat EX380 Practice Test & Real Exam Questions
Kubeconfig Management - Set Credentials in Kubeconfig
Correct Answer:
See the solution below in Explanation:
Explanation:
Step 1: Ensure the client certificate and private key files are available.
The lab uses audit.crt and tls.key.
Step 2: Run the command:
oc config set-credentials audit --client-certificate audit.crt --client-key tls.key --embed-certs --kubeconfig audit.config Step 3: Confirm the user entry is written.
The lab output shows:
User "audit" set.
Detailed explanation:
This command creates or updates the audit user entry inside the kubeconfig file audit.config. It points the user to a client certificate and private key, and the --embed-certs option stores certificate material directly inside the kubeconfig rather than only referencing external files. That makes the kubeconfig more portable because it can be moved and used without separately copying the certificate files, provided the embedded content is valid. In certificate-based authentication, the private key proves client possession while the certificate presents the approved identity. If the certificate and key do not match, authentication will fail. This step does not yet define what cluster or namespace the user works against; it only defines the credential identity.
Explanation:
Step 1: Ensure the client certificate and private key files are available.
The lab uses audit.crt and tls.key.
Step 2: Run the command:
oc config set-credentials audit --client-certificate audit.crt --client-key tls.key --embed-certs --kubeconfig audit.config Step 3: Confirm the user entry is written.
The lab output shows:
User "audit" set.
Detailed explanation:
This command creates or updates the audit user entry inside the kubeconfig file audit.config. It points the user to a client certificate and private key, and the --embed-certs option stores certificate material directly inside the kubeconfig rather than only referencing external files. That makes the kubeconfig more portable because it can be moved and used without separately copying the certificate files, provided the embedded content is valid. In certificate-based authentication, the private key proves client possession while the certificate presents the approved identity. If the certificate and key do not match, authentication will fail. This step does not yet define what cluster or namespace the user works against; it only defines the credential identity.
Integrate OpenShift with Keycloak (OIDC)
Task Information : Add a Keycloak (RH SSO) OpenID Connect identity provider to OpenShift OAuth and verify redirect/login works.
Task Information : Add a Keycloak (RH SSO) OpenID Connect identity provider to OpenShift OAuth and verify redirect/login works.
Correct Answer:
See the solution below in Explanation:
Explanation:
* Collect Keycloak details
* Issuer URL (realm), client ID, and client secret.
* Confirm Keycloak client has correct redirect URI for OpenShift OAuth callback.
* Create a secret with the OIDC client secret
* oc -n openshift-config create secret generic keycloak-oidc-secret \
* --from-literal=clientSecret=' < SECRET > '
* OAuth reads the OIDC client secret from this secret.
* Edit OAuth and add OpenID provider
* oc edit oauth cluster
Add under spec.identityProviders:
- name: keycloak
mappingMethod: claim
type: OpenID
openID:
issuer: "https://keycloak.example.com/realms/ocp"
clientID: "openshift"
clientSecret:
name: keycloak-oidc-secret
claims:
preferredUsername: ["preferred_username"]
name: ["name"]
email: ["email"]
* issuer must match Keycloak realm issuer URL.
* claims determines which token claims map to OpenShift username/name/email.
* Restart OAuth pods
* oc -n openshift-authentication delete pod -l app=oauth-openshift
* Verify by logging in through the web console
* You should be redirected to Keycloak, authenticate, then return to OpenShift.
* Confirm users/identities:
* oc get users
* oc get identities
Explanation:
* Collect Keycloak details
* Issuer URL (realm), client ID, and client secret.
* Confirm Keycloak client has correct redirect URI for OpenShift OAuth callback.
* Create a secret with the OIDC client secret
* oc -n openshift-config create secret generic keycloak-oidc-secret \
* --from-literal=clientSecret=' < SECRET > '
* OAuth reads the OIDC client secret from this secret.
* Edit OAuth and add OpenID provider
* oc edit oauth cluster
Add under spec.identityProviders:
- name: keycloak
mappingMethod: claim
type: OpenID
openID:
issuer: "https://keycloak.example.com/realms/ocp"
clientID: "openshift"
clientSecret:
name: keycloak-oidc-secret
claims:
preferredUsername: ["preferred_username"]
name: ["name"]
email: ["email"]
* issuer must match Keycloak realm issuer URL.
* claims determines which token claims map to OpenShift username/name/email.
* Restart OAuth pods
* oc -n openshift-authentication delete pod -l app=oauth-openshift
* Verify by logging in through the web console
* You should be redirected to Keycloak, authenticate, then return to OpenShift.
* Confirm users/identities:
* oc get users
* oc get identities
Maintain group synchronization on a schedule (CronJob)
Task Information : Create a CronJob that runs LDAP group sync on a schedule using a service account that has the required permissions.
Task Information : Create a CronJob that runs LDAP group sync on a schedule using a service account that has the required permissions.
Correct Answer:
See the solution below in Explanation:
Explanation:
* Create a namespace for the sync job
* oc new-project id-sync
* Keeps the automation components organized.
* Create a service account for the sync job
* oc -n id-sync create sa group-sync
* CronJob runs under this SA identity.
* Grant cluster permissions to manage groups
* oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:id-sync:group-sync
* In real environments you should scope down, but lab Task SIMULATIONs often accept cluster- admin for speed.
* Create a ConfigMap for groupsync.yaml and Secret(s) for bind password/CA
* Mount them into the job container.
* Create CronJob to run group sync
* Command inside job:
* oc adm groups sync --sync-config=/config/groupsync.yaml --confirm
* The CronJob ensures periodic reconciliation with LDAP.
* Verify job runs
* oc -n id-sync get cronjob
* oc -n id-sync get jobs
* oc -n id-sync logs job/ < job-name >
Explanation:
* Create a namespace for the sync job
* oc new-project id-sync
* Keeps the automation components organized.
* Create a service account for the sync job
* oc -n id-sync create sa group-sync
* CronJob runs under this SA identity.
* Grant cluster permissions to manage groups
* oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:id-sync:group-sync
* In real environments you should scope down, but lab Task SIMULATIONs often accept cluster- admin for speed.
* Create a ConfigMap for groupsync.yaml and Secret(s) for bind password/CA
* Mount them into the job container.
* Create CronJob to run group sync
* Command inside job:
* oc adm groups sync --sync-config=/config/groupsync.yaml --confirm
* The CronJob ensures periodic reconciliation with LDAP.
* Verify job runs
* oc -n id-sync get cronjob
* oc -n id-sync get jobs
* oc -n id-sync logs job/ < job-name >
Resolve group synchronization conflicts (prune stale data)
Task Information : Run group sync with pruning to remove stale OpenShift group memberships that no longer exist in LDAP.
Task Information : Run group sync with pruning to remove stale OpenShift group memberships that no longer exist in LDAP.
Correct Answer:
See the solution below in Explanation:
Explanation:
* Run group sync with prune controls
* oc adm groups sync --sync-config=groupsync.yaml --confirm --prune-whitelist=/tmp/whitelist.txt
* Prune removes stale memberships/groups, but whitelist protects selected groups from pruning.
* Verify group membership reflects LDAP
* oc describe group < groupname >
* Confirms removed users are no longer listed.
Explanation:
* Run group sync with prune controls
* oc adm groups sync --sync-config=groupsync.yaml --confirm --prune-whitelist=/tmp/whitelist.txt
* Prune removes stale memberships/groups, but whitelist protects selected groups from pruning.
* Verify group membership reflects LDAP
* oc describe group < groupname >
* Confirms removed users are no longer listed.
Add a second Identity Provider (HTPasswd) alongside LDAP
Task Information : Configure multiple identity providers by adding an HTPasswd IDP without removing the existing LDAP IDP.
Task Information : Configure multiple identity providers by adding an HTPasswd IDP without removing the existing LDAP IDP.
Correct Answer:
See the solution below in Explanation:
Explanation:
* Create a local htpasswd file with a test user
* htpasswd -c -B -b /tmp/htpass.txt testuser RedHat123!
* -c creates a new file (use only once).
* -B uses bcrypt hashing (recommended).
* -b supplies password non-interactively (good for labs).
* Create the HTPasswd secret in openshift-config
* oc -n openshift-config create secret generic htpass-secret --from-file=htpasswd=/tmp/htpass.txt
* OAuth reads the htpasswd key from this secret.
* Edit OAuth and add the HTPasswd provider (keep LDAP intact)
* oc edit oauth cluster
Add another entry under spec.identityProviders:
- name: local-htpasswd
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpass-secret
* This adds a second login option while preserving LDAP.
* Restart OAuth pods
* oc -n openshift-authentication delete pod -l app=oauth-openshift
* Ensures the updated list of identity providers is loaded.
* Verify login works for htpasswd user
* Log in via console using testuser.
* Confirm the user is created:
* oc get user testuser
Explanation:
* Create a local htpasswd file with a test user
* htpasswd -c -B -b /tmp/htpass.txt testuser RedHat123!
* -c creates a new file (use only once).
* -B uses bcrypt hashing (recommended).
* -b supplies password non-interactively (good for labs).
* Create the HTPasswd secret in openshift-config
* oc -n openshift-config create secret generic htpass-secret --from-file=htpasswd=/tmp/htpass.txt
* OAuth reads the htpasswd key from this secret.
* Edit OAuth and add the HTPasswd provider (keep LDAP intact)
* oc edit oauth cluster
Add another entry under spec.identityProviders:
- name: local-htpasswd
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpass-secret
* This adds a second login option while preserving LDAP.
* Restart OAuth pods
* oc -n openshift-authentication delete pod -l app=oauth-openshift
* Ensures the updated list of identity providers is loaded.
* Verify login works for htpasswd user
* Log in via console using testuser.
* Confirm the user is created:
* oc get user testuser
