kubectl edit cm fluentd -n openshift -logging Add the Elasticsearch output: <match **> @type elasticsearch host elasticsearch.example.com port 9200 logstash_format true </match> 2. Restart Fluentd: kubectl rollout restart daemonset/fluentd -n openshift -logging 3. Verify logs in Elasticsearch. Explanation: Integrating with Elasticsearch centralizes log management and supports advanced querying and visualization, aiding in operational monitoring. Use OpenShift product documentation to identify the steps for upgrading the cluster from version X to version Y. Demonstrate how to validate that the upgrade completed successfully. ee the Solution below. Solution: 1. Access the OpenShift documentation: oc adm upgrade 2. Perform a pre-upgrade check: oc adm preflight -check 3. Start the upgrade: oc adm upgrade --to-latest 4. Verify the cluster version: oc version Explanation:
Configure a DeploymentConfig to trigger a rollback on readiness probe failure. Validate rollback behavior. ee the Solution below. Solution: 1. Add a readiness probe to the DeploymentConfig: spec: containers: - name: app-container readinessProbe: httpGet: path: / port: 80 2. Deploy a broken application version: oc set image dc/my -app app -container=nginx:broken 3. Validate rollback: oc rollout undo dc/my -app Explanation: Automating rollbacks on readiness probe failures ensures deployments revert to stable states, minimizing downtime. Set up a DeploymentConfig with an environment variable that automatically updates on ConfigMap changes. Validate the dynamic update. ee the Solution below. Solution: 1. Create a ConfigMap: oc create configmap env -config --from-literal=ENV_VAR=production 2. Update the DeploymentConfig: envFrom: - configMapRef: name: env-config
3. Change the ConfigMap and validate the update: oc create configmap env-config --from-literal=ENV_VAR=staging -o yaml --dry-run=client | oc apply -f - oc get pods Explanation: Dynamic updates to environment variables from ConfigMaps improve flexibility, allowing configuration changes without redeployments. Configure a DeploymentConfig to use a custom lifecycle pre-hook for validating configurations before deployment. Validate the hook’s execution. ee the Solution below. Solution: 1. Add a pre -hook to the DeploymentConfig: spec: strategy: type: Rolling rollingParams: pre: execNewPod: containerName: app-container command: - sh - -c - "curl http://localhost/validate" 2. Apply the DeploymentConfig: oc apply -f deploymentconfig.yaml 3. Trigger a deployment and validate: oc rollout latest dc/my -app oc logs -f dc/my -app Explanation: Lifecycle hooks validate preconditions during deployments, ensuring readiness before proceeding, which reduces deployment errors.
Use an ImageStream to manage different versions of an application and configure a policy for automated updates. Validate the behavior with a new image version. ee the Solution below. Solution: 1. Create an ImageStream with automated updates: spec: tags: - name: stable from: kind: DockerImage name: nginx:1.21 importPolicy: scheduled: true 2. Apply the ImageStream: oc apply -f imagestream.yaml 3. Tag a new image version: oc tag nginx:1.22 nginx -stream:stable 4. Validate the deployment update: oc get pods Explanation: Automated updates with ImageStreams ensure applications stay up-to-date with the latest image versions, reducing manual intervention. Implement a BuildConfig that rebuilds an application whenever the source repository changes. Validate the automated build process. ee the Solution below. Solution: 1. Create a BuildConfig:
apiVersion: build.openshift.io/v1 kind: BuildConfig metadata: name: app-build spec: source: git: uri: "https://github.com/example/repo.git" strategy: type: Docker triggers: - type: GitHub github: secret: webhook -secret 2. Apply the BuildConfig: oc apply -f buildconfig.yaml 3. Push a change to the repository and validate: oc get builds Explanation: BuildConfigs with Git triggers automate builds upon code changes, enabling seamless CI/CD workflows. Configure a rolling update strategy with a specified maximum unavailable and surge value. Validate the update process. ee the Solution below. Solution: 1. Add a rolling update strategy to the DeploymentConfig: spec: strategy: type: Rolling rollingParams: maxUnavailable: 1 maxSurge: 2 2. Apply the DeploymentConfig: oc apply -f deploymentconfig.yaml
Solution: 1. Create a Headless Service YAML file: apiVersion: v1 kind: Service metadata: name: headless -service spec: clusterIP: None selector: app: my-stateful -app ports: - protocol: TCP port: 80 2. Apply the Service and verify DNS resolution: kubectl apply -f headless -service.yaml kubectl exec <pod -name> -- nslookup headless -service Explanation: Headless Services provide direct access to individual pod IPs, which is essential for StatefulSet workloads. Deploy an application using a Kubernetes CronJob that runs every 5 minutes. Validate its execution. ee the Solution below. Solution: 1. Create a CronJob YAML file cronjob.yaml: apiVersion: batch/v1 kind: CronJob metadata: name: my-cronjob spec: schedule: "*/5 * * * *" jobTemplate: spec: template: spec: containers: - name: my -container