Docker & Kubernetes Test 2

    Question 1DOCKER- Inspecting Images

    Which command lists all Docker images on the local system?

    Question 2KUBERNETES- Code Snippet (Service YAML)

    What type of Service is defined by this YAML?

    apiVersion: v1 kind: Service metadata: name: myapp-service spec: selector: app: myapp ports: - protocol: TCP port: 80 targetPort: 8080 type: ClusterIP

    Question 3KUBERNETES- Ingress Purpose

    What is the main role of an Ingress in Kubernetes?

    Question 4KUBERNETES- Code Snippet (Mount ConfigMap as Volume)

    What does this snippet achieve?

    volumes: - name: config-volume configMap: name: app-config containers: - name: app image: myapp:latest volumeMounts: - name: config-volume mountPath: /etc/config

    Question 5KUBERNETES- Code Snippet (Pod with Resource Limits)

    What does this configuration do?

    containers: - name: myapp image: myapp:latest resources: requests: cpu: "250m" memory: "128Mi" limits: cpu: "500m" memory: "256Mi"

    Question 6DOCKER- Code Snippet (Run Container With Port Mapping)

    What does this command do?

    docker run -d -p 8080:8080 myapp

    Question 7KUBERNETES- ConfigMaps Purpose

    What is the purpose of a ConfigMap in Kubernetes?

    Question 8KUBERNETES- Code Snippet (Ingress Example)

    What is the function of this YAML snippet?

    apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp-ingress spec: rules: - host: myapp.example.com http: paths: - path: / pathType: Prefix backend: service: name: myapp-service port: number: 80

    Question 9KUBERNETES- Secrets Base64 Encoding

    How must data in Kubernetes Secrets be stored?

    Question 10KUBERNETES- Monitoring with Metrics Server

    What role does the Metrics Server play in Kubernetes monitoring?

    Question 11DOCKER- Volumes Purpose

    Why are Docker volumes used?

    Question 12KUBERNETES- Code Snippet (Apply Deployment)

    What does this command do?

    kubectl apply -f myapp-deployment.yaml

    Question 13KUBERNETES- Network Policies

    What is the purpose of a NetworkPolicy in Kubernetes?

    Question 14KUBERNETES- Code Snippet (Secret YAML)

    What is this YAML doing?

    apiVersion: v1 kind: Secret metadata: name: db-secret type: Opaque data: DB_USER: YWRtaW4= DB_PASSWORD: cGFzc3dvcmQ=

    Question 15KUBERNETES- Logging Basics

    By default, how are logs generated by Kubernetes pods accessed?

    Question 16DOCKER- Code Snippet (Attach Volume)

    What does this command achieve?

    docker run -d -v /host/data:/app/data myapp

    Question 17KUBERNETES- Scaling Pods

    How can you scale a Deployment named myapp-deploy to 5 replicas?

    Question 18KUBERNETES- Code Snippet (Simple NetworkPolicy)

    What does this NetworkPolicy allow?

    apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-frontend spec: podSelector: matchLabels: role: backend ingress: - from: - podSelector: matchLabels: role: frontend

    Question 19KUBERNETES- Consume Secret as Environment Variable

    How can a pod use a Secret as an environment variable?

    Question 20KUBERNETES- Centralized Logging Solutions

    Which of the following stacks is commonly used for centralized logging in Kubernetes?