Solve this question on: ssh cluster3-controlplane
Part I:
Create a ClusterIP service with name of service-3421-svcn in the spectra-1267 namespace, which should expose the pods, namely, pod-23 and pod-21, with port set to 8080 and targetport to 80.
Part II:
Store the pod names and their IP addresses from the spectra-1267 namespace at /root/pod_ips_cka05_svcn where the output is sorted by their IPs.
Please ensure the format as shown below:
POD_NAME IP_ADDR
pod-1 ip-1
pod-3 ip-2
pod-2 ip-3
...
My solution:
cluster3-controlplane ~ ➜ k -n spectra-1267 get svc service-3421-svcn -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: “2026-03-18T09:04:52Z”
labels:
mode: exam
type: external
name: service-3421-svcn
namespace: spectra-1267
resourceVersion: “2146”
uid: e4644947-d853-423a-a43f-58f986c69a83
spec:
clusterIP: 10.43.94.241
clusterIPs:
- 10.43.94.241
internalTrafficPolicy: Cluster
ipFamilies: - IPv4
ipFamilyPolicy: SingleStack
ports: - port: 8080
protocol: TCP
targetPort: 80
selector:
mode: exam
type: external
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
Failed as exam solution
cluster3-controlplane ~ ➜ cat service-3421-svcn.yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: service-3421-svcn
name: service-3421-svcn
namespace: spectra-1267
spec:
ports:
- name: 8080-80
port: 8080
protocol: TCP
targetPort: 80
selector:
app: service-3421-svcn # delete
mode: exam # add
type: external # add
type: ClusterIP
status:
loadBalancer: {}
help me