第七題:Service:
題目:Create a Pod as follows:
- Name: jenkins
- Using image: jenkins
- In a new Kubernetes namespce named website-frontend
解題思路:
本題考的是Namespace以及Pod的創(chuàng)建方式甸各,屬于基礎(chǔ)題型:
具體可參考:https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/
解題步驟:
- 步驟1 :新建一個(gè)namespace:
sudo kubectl create ns website-frontend
- 步驟2: 在該ns下創(chuàng)建pod:
sudo kubectl run jenkins --image=jenkins --generator=run-pod/v1 --dry-run -o yaml > jenkins.yaml
修改yaml文件:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: jenkins
name: jenkins
namespace: website-frontend
spec:
containers:
- image: jenkins
name: jenkins
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
website-frontend下創(chuàng)建pod