OpenShift CRCを立てたのでとりあえずPodでも作ってみた。
今回はGUIでポチポチしてもよいのですがせっかくなのでマニフェストで作ってみた。(´ω`)
前提
・OpenShift CRCがインストールされていること
実践!
1.NginxPod作成
1-1.OpenShift CRCへCLIでログイン
$ oc login -u kubeadmin -p $(cat /home/openshift/.crc/machines/crc/kubeadmin-password) ※kubeadminのパスワードなんて覚えてられないので、デフォルトで作成されるパスワードが記載されたファイルを参照します。どっちを覚えるかですが、、、
1-2.マニフェスト作成
$ vi create-pod-nginx.yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app: web-nginx name: web-nginx spec: replicas: 3 selector: matchLabels: app: web-nginx template: metadata: labels: app: web-nginx spec: containers: - image: nginx name: nginx ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: web-nginx spec: selector: app: web-nginx type: NodePort ports: - port: 80 nodePort: 30080
1-3.マニフェスト適用
$ oc apply -f create-pod-nginx.yaml Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost") deployment.apps/web-nginx created service/web-nginx created ※Warningが出てますがいったん無視で。。 $ oc get pod NAME READY STATUS RESTARTS AGE web-nginx-54d6bd4f64-6jl9m 0/1 ContainerCreating 0 11s web-nginx-54d6bd4f64-d6qm7 0/1 ContainerCreating 0 11s web-nginx-54d6bd4f64-shjbb 0/1 ContainerCreating 0 11s ※今回は3台、作成中になってます。 $ oc get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.217.4.1 <none> 443/TCP 221d openshift ExternalName <none> kubernetes.default.svc.cluster.local <none> 221d web-nginx NodePort 10.217.5.151 <none> 80:30080/TCP 69s ※Serviceもしっかり作られてる!
感想
kubernetesのマニフェストがそのまま使えた!