Complete the code to specify the TLS secret in the Kubernetes service.
apiVersion: v1 kind: Service metadata: name: my-service spec: ports: - port: 443 targetPort: 8443 selector: app: my-app tls: secretName: [1]
The secretName field must point to the TLS secret that contains the certificates for mutual TLS. Here, my-tls-secret is the correct secret name.
Complete the code to mount the TLS certificates as volumes in the pod.
apiVersion: v1
kind: Pod
metadata:
name: my-app-pod
spec:
containers:
- name: my-app-container
image: my-app-image
volumeMounts:
- name: tls-certs
mountPath: [1]
readOnly: true
volumes:
- name: tls-certs
secret:
secretName: my-tls-secretreadOnly: true for the volume mountThe TLS certificates are commonly mounted at /etc/tls inside the container for the application to use them for mutual TLS.
Fix the error in the Ingress TLS configuration by completing the missing field.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
spec:
tls:
- hosts:
- myapp.example.com
[1]: my-tls-secret
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 443certificate or tlsSecretThe correct field to specify the TLS secret in an Ingress resource is secretName. This tells Kubernetes which secret contains the TLS certificate and key.
Fill both blanks to create a Kubernetes NetworkPolicy that allows only mutual TLS traffic on port 443.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-mtls
spec:
podSelector:
matchLabels:
app: my-app
policyTypes:
- Ingress
ingress:
- ports:
- protocol: [1]
port: 443
from:
- namespaceSelector:
matchLabels:
[2]: trustedThe protocol for TLS traffic is TCP. The namespaceSelector uses a label key, here environment, to select trusted namespaces allowed to communicate.
Fill all three blanks to define a Kubernetes Secret manifest for mutual TLS certificates.
apiVersion: v1 kind: Secret metadata: name: my-tls-secret namespace: default type: [1] data: tls.crt: [2] tls.key: [3]
The secret type for TLS certificates is kubernetes.io/tls. The tls.crt and tls.key fields contain base64 encoded certificate and private key data respectively.