EX280 Demo
EX280 Demo
EX280 Exam
Red Hat Certified OpenShift
www.certsland.com
Questions & Answers PDF Page 2
Question: 1
You are tasked with deploying a highly available application in OpenShift. Create a Deployment using
YAML to deploy the nginx container with three replicas, ensuring that it runs successfully. Verify that the
Deployment is active, all replicas are running, and the application can serve requests properly. Provide a
complete walkthrough of the process, including necessary commands to check deployment status.
Solution:
1. Create a Deployment YAML file named nginx-deployment.yaml with the following content:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
www.certsland.com
Questions & Answers PDF Page 3
5. Use the NodePort and cluster IP to confirm that the application is serving requests.
Explanation:
Deployments provide a scalable and declarative way to manage applications. YAML manifests ensure
the configuration is consistent, while NodePort services expose the application for testing. Verifying
replicas ensures that the application is running as expected and resilient.
Question: 2
Your team requires an application to load specific configuration data dynamically during runtime. Create
a ConfigMap to hold key-value pairs for application settings, and update an existing Deployment to use
this ConfigMap. Provide a complete YAML definition for both the ConfigMap and the updated
Deployment, and demonstrate how to validate that the configuration is applied correctly.
Solution:
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
APP_ENV: production
APP_DEBUG: "false"
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-deployment
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
www.certsland.com
Questions & Answers PDF Page 4
spec:
containers:
- name: app-container
image: nginx:latest
env:
- name: APP_ENV
valueFrom:
configMapKeyRef:
name: app-config
key: APP_ENV
- name: APP_DEBUG
valueFrom:
configMapKeyRef:
name: app-config
key: APP_DEBUG
Explanation:
ConfigMaps decouple configuration data from the application code, enabling environment-specific
settings without altering the deployment logic. Using environment variables from ConfigMaps ensures
flexibility and reduces maintenance complexity.
Question: 3
Perform a rolling update of an application to upgrade the nginx image from 1.19 to 1.21. Ensure zero
downtime during the update and verify that all replicas are running the new version.
Solution:
www.certsland.com
Questions & Answers PDF Page 5
Explanation:
Rolling updates replace pods incrementally, ensuring that applications remain available during the
update process. Monitoring confirms the successful rollout.
Question: 4
Deploy an application across multiple namespaces using a common Deployment YAML file. Include
steps to create the namespaces, apply the deployment, and verify that the pods are running in each
namespace.
Solution:
1. Create namespaces:
apiVersion: apps/v1
kind: Deployment
metadata:
name: multi-namespace-app
spec:
replicas: 2
selector:
matchLabels:
app: sample-app
template:
metadata:
labels:
app: sample-app
spec:
containers:
- name: app-container
image: nginx:latest
www.certsland.com
Questions & Answers PDF Page 6
Explanation:
Deploying across namespaces ensures workload isolation while reusing common configurations.
Verification confirms that resources are created and operational.
Question: 5
Configure an Ingress resource to expose an application using a custom domain name. Include steps to
create the Ingress YAML and validate that the domain resolves to the application.
Solution:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: custom-domain.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-service
port:
number: 80
4. Verify accessibility:
curl http://custom-domain.example.com
Explanation:
www.certsland.com
Questions & Answers PDF Page 7
Ingress provides an HTTP(S) layer to expose services using custom domains, offering centralized traffic
management.
Question: 6
Configure a StatefulSet to deploy a MySQL database with persistent storage. Include steps to define the
StatefulSet, create a PersistentVolume (PV) and PersistentVolumeClaim (PVC), and verify the database
is running correctly.
Solution:
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/mysql
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
spec:
serviceName: "mysql"
replicas: 1
www.certsland.com
Questions & Answers PDF Page 8
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.7
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: rootpassword
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
volumeClaimTemplates:
- metadata:
name: mysql-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi
Explanation:
StatefulSets ensure stable identities for applications requiring persistent data, like databases. Coupling
them with PVs and PVCs ensures data persistence across restarts.
Question: 7
Diagnose and fix an issue where a Deployment fails due to exceeding the configured ResourceQuota.
www.certsland.com
Questions & Answers PDF Page 9
Solution:
resources:
requests:
cpu: "100m"
memory: "128Mi"
Explanation:
ResourceQuotas ensure fair resource distribution. Adjusting Deployment configurations avoids conflicts
and ensures compliance.
Question: 8
Set up and validate OpenShift pod affinity to ensure that pods are scheduled on the same node.
Solution:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- my-app
topologyKey: "kubernetes.io/hostname"
www.certsland.com
Questions & Answers PDF Page 10
Explanation:
Pod affinity ensures co-location of related workloads, optimizing resource usage and inter-pod
communication.
Question: 9
Solution:
Explanation:
Horizontal scaling adds replicas, ensuring applications handle increased traffic effectively.
Question: 10
Update an existing Deployment to add a readiness probe. Validate that the readiness probe works
correctly.
Solution:
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
www.certsland.com
Questions & Answers PDF Page 11
Explanation:
Readiness probes ensure that only fully initialized and functional pods receive traffic, improving
application reliability.
Question: 11
Deploy an application using Kustomize with environment-specific overlays for dev and prod. Validate the
deployment.
Solution:
# base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: app-container
image: nginx
# overlays/dev/kustomization.yaml
resources:
- ../../base
www.certsland.com
Questions & Answers PDF Page 12
- replicas:
my-app: 1
# overlays/prod/kustomization.yaml
resources:
- ../../base
replicas:
my-app: 3
Explanation:
Question: 12
Deploy a Job that runs a database migration script. Validate its execution and logs.
Solution:
apiVersion: batch/v1
kind: Job
metadata:
name: db-migration
spec:
template:
spec:
containers:
- name: migration
image: postgres
command: ["sh", "-c", "psql -U user -d dbname -f /scripts/migration.sql"]
volumeMounts:
- name: script-volume
mountPath: /scripts
volumes:
- name: script-volume
configMap:
name: migration-script
restartPolicy: Never
3. Validate execution:
Explanation:
Jobs are ideal for executing one-time tasks like database migrations. Logs help verify task success or
troubleshoot issues.
Question: 13
Create a ConfigMap with multiple configuration keys. Inject them as individual environment variables into
a pod. Validate their presence.
Solution:
1. Create a ConfigMap:
envFrom:
- configMapRef:
name: multi-config
Explanation:
ConfigMaps with multiple keys allow flexible configuration injection into pods, supporting modular and
scalable application designs.
Question: 14
Create a StatefulSet for a Cassandra database cluster with non-shared storage for each node. Validate
the cluster functionality after restarting pods.
www.certsland.com
Questions & Answers PDF Page 14
Solution:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cassandra
spec:
serviceName: "cassandra-service"
replicas: 3
selector:
matchLabels:
app: cassandra
template:
metadata:
labels:
app: cassandra
spec:
containers:
- name: cassandra
image: cassandra:3.11
ports:
- containerPort: 9042
volumeMounts:
- name: cassandra-data
mountPath: /var/lib/cassandra
volumeClaimTemplates:
- metadata:
name: cassandra-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi
cqlsh <cassandra-pod-ip> -e "INSERT INTO keyspace.table (id, value) VALUES (1, 'data');"
www.certsland.com
Questions & Answers PDF Page 15
Explanation:
StatefulSets ensure each Cassandra node has its own persistent storage, allowing data retention even if
pods are restarted or moved.
Question: 15
Deploy an application that dynamically provisions storage using a CSI driver. Validate the storage
binding.
Solution:
1. Install the CSI driver for your environment (e.g., AWS EBS, Ceph):
provisioner: ebs.csi.aws.com
Explanation:
CSI drivers provide a standardized way to integrate external storage solutions with Kubernetes, enabling
dynamic provisioning.
Question: 16
Manually configure resource quotas for a namespace to limit total application resource usage. Validate
enforcement.
Solution:
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-resources
spec:
www.certsland.com
Questions & Answers PDF Page 16
hard:
requests.cpu: "2"
requests.memory: "2Gi"
limits.cpu: "4"
limits.memory: "4Gi"
Explanation:
Resource quotas restrict namespace resource usage, preventing excessive consumption and
maintaining cluster fairness.
Question: 17
Solution:
oc apply -f blue-deploymentconfig.yaml
oc apply -f green-deploymentconfig.yaml
curl http://<app-url>
Explanation:
Question: 18
www.certsland.com
Questions & Answers PDF Page 17
Modify the password policy for HTPasswd users to enforce complexity requirements.
Solution:
Explanation:
Enforcing complex passwords improves account security, reducing the risk of unauthorized access.
Question: 19
Set up an OAuth identity provider to integrate with an external authentication service. Validate user login
through the external provider.
Solution:
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: external-idp
type: OpenID
mappingMethod: claim
openID:
clientID: my-client-id
clientSecret:
name: my-client-secret
claims:
preferredUsername:
- email
www.certsland.com
Questions & Answers PDF Page 18
name:
- name
email:
- email
urls:
authorize: https://idp.example.com/authorize
token: https://idp.example.com/token
userInfo: https://idp.example.com/userinfo
oc apply -f oauth-config.yaml
oc login --token=<external-idp-token>
Explanation:
Integrating external identity providers centralizes authentication management and supports single sign-
on (SSO) capabilities.
Question: 20
Restrict project creation to specific users. Validate the restricted behavior for other users.
Solution:
Explanation:
Restricting project creation ensures tighter control over resource usage and aligns with organizational
policies.
www.certsland.com
Questions & Answers PDF Page 19
Question: 21
Configure and test application network policies to restrict communication between pods in OpenShift.
Solution:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-app-communication
namespace: default
spec:
podSelector:
matchLabels:
app: my-app
ingress:
- from:
- podSelector:
matchLabels:
app: my-other-app
oc apply -f networkpolicy.yaml
Explanation:
Network policies enable fine-grained control over traffic between pods, which can be used to restrict
access based on labels or namespaces.
Question: 22
Troubleshoot a failed TLS handshake between the ingress controller and a backend service.
Solution:
Explanation:
TLS handshake failures are often due to mismatched certificates or misconfigured routes. Logs and
secret validation help diagnose and resolve the issue.
Question: 23
Configure an internal-only service accessible by other services in the cluster but not externally. Validate
restricted access.
Solution:
apiVersion: v1
kind: Service
metadata:
name: internal-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
curl http://<cluster-external-ip>:80
Explanation:
www.certsland.com
Questions & Answers PDF Page 21
Internal-only services improve security by restricting external access, suitable for backend services that
don’t require public exposure.
Question: 24
Create a custom health check for an application and configure a network policy to block traffic to
unhealthy pods.
Solution:
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 3
periodSeconds: 5
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: block-unhealthy-pods
namespace: dev-namespace
spec:
podSelector:
matchExpressions:
- key: health
operator: In
values:
- healthy
Explanation:
Custom health checks and network policies ensure that only healthy pods serve traffic, improving
application reliability.
Question: 25
Configure a default project template to automatically apply quotas and limits when new projects are
www.certsland.com
Questions & Answers PDF Page 22
Solution:
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: default-project-template
objects:
- apiVersion: v1
kind: ResourceQuota
metadata:
name: default-quota
spec:
hard:
pods: "10"
- apiVersion: v1
kind: LimitRange
metadata:
name: default-limit
spec:
limits:
- type: Container
default:
cpu: "1"
memory: "512Mi"
oc create -f default-project-template.yaml
Explanation:
Default project templates automate resource governance for new projects, ensuring consistent
application of quotas and limits.
Question: 26
www.certsland.com
Questions & Answers PDF Page 23
Configure a project quota to limit the total storage capacity of PersistentVolumeClaims (PVCs) in a
namespace. Validate by exceeding the storage limit.
Solution:
apiVersion: v1
kind: ResourceQuota
metadata:
name: pvc-storage-quota
namespace: storage-project
spec:
hard:
requests.storage: "50Gi"
oc apply -f pvc-storage-quota.yaml
Explanation:
PVC storage quotas ensure storage usage within a namespace does not exceed the allocated capacity,
preserving cluster resources
Question: 27
Create a project template to include a default Deployment, Service, and Route for a new application.
Validate by creating a project and checking all resources.
Solution:
apiVersion: template.openshift.io/v1
kind: Template
metadata:
www.certsland.com
Questions & Answers PDF Page 24
name: project-template-app
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: app-deployment
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: nginx
- apiVersion: v1
kind: Service
metadata:
name: app-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: app-route
spec:
host: myapp.example.com
to:
kind: Service
name: app-service
oc create -f project-template-app.yaml
4. Validate resources:
Explanation:
Combining Deployment, Service, and Route in a project template automates the setup of a fully
functional application stack for new projects.
Question: 28
Solution:
oc apply -f
https://raw.githubusercontent.com/redhat-developer/gitops-operator/main/deploy/crds/gitops-operator.ya
ml
Explanation:
The OpenShift GitOps Operator simplifies GitOps workflows, enabling application and infrastructure
automation.
Question: 29
Install the Service Mesh Operator for all namespaces in the cluster. Validate its deployment.
Solution:
oc apply -f - <<EOF
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
www.certsland.com
Questions & Answers PDF Page 26
metadata:
name: servicemeshoperator
namespace: openshift-operators
spec:
channel: stable
name: servicemeshoperator
source: redhat-operators
sourceNamespace: openshift-marketplace
EOF
2. Validate deployment:
Explanation:
The Service Mesh Operator enables service-to-service communication with features like traffic control,
observability, and security.
Question: 30
Create a secret for a Docker registry credential and use it to pull a private image. Validate the
deployment.
Solution:
apiVersion: v1
kind: Pod
metadata:
name: private-registry-pod
namespace: app-security
spec:
imagePullSecrets:
- name: my-docker-secret
containers:
www.certsland.com
Questions & Answers PDF Page 27
- name: private-app
image: <registry-url>/<image>:<tag>
Explanation:
Docker registry secrets enable secure authentication to private image repositories, ensuring only
authorized access.
https://www.certsland.com/ex280-dumps/
[Limited Time Offer] Use Coupon " SAVE20 " for extra 20%
discount on the purchase of PDF file. Test your
EX280 preparation with actual exam questions
www.certsland.com