This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.15.2. Pod 사전 설정 생성
다음 예제에서는 Pod 사전 설정을 생성하고 사용하는 방법을 보여줍니다.
- Admission Controller 추가
- 관리자는 /etc/origin/master/master-config.yaml 파일을 확인하여 Pod 사전 설정 승인 컨트롤러 플러그인이 있는지 확인할 수 있습니다. 승인 컨트롤러가 없는 경우 다음을 사용하여 플러그인을 추가합니다.
admissionConfig: pluginConfig: PodPreset: configuration: kind: DefaultAdmissionConfig apiVersion: v1 disable: false
admissionConfig:
pluginConfig:
PodPreset:
configuration:
kind: DefaultAdmissionConfig
apiVersion: v1
disable: false
그런 다음 OpenShift Container Platform 서비스를 다시 시작하십시오.
systemctl restart atomic-openshift-master-api atomic-openshift-master-controllers
# systemctl restart atomic-openshift-master-api atomic-openshift-master-controllers
- Pod Preset 생성
-
관리자 또는 개발자는
settings.k8s.io/v1alpha1
API, 삽입할 정보, Pod와 일치하는 라벨 선택기를 사용하여 사전 정의된 Pod를 생성합니다.
kind: PodPreset apiVersion: settings.k8s.io/v1alpha1 metadata: name: allow-database spec: selector: matchLabels: role: frontend env: - name: DB_PORT value: "6379" volumeMounts: - mountPath: /cache name: cache-volume volumes: - name: cache-volume emptyDir: {}
kind: PodPreset
apiVersion: settings.k8s.io/v1alpha1
metadata:
name: allow-database
spec:
selector:
matchLabels:
role: frontend
env:
- name: DB_PORT
value: "6379"
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
- Pod 생성
개발자는 Pod 사전 설정의 라벨 선택기와 일치하는 라벨을 사용하여 Pod를 생성합니다.
Pod 사전 설정의 라벨 선택기와 일치하는 라벨을 사용하여 표준 Pod 사양을 생성합니다.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: website labels: app: website role: frontend spec: containers: - name: website image: ecorp/website ports: - containerPort: 80
apiVersion: v1 kind: Pod metadata: name: website labels: app: website role: frontend spec: containers: - name: website image: ecorp/website ports: - containerPort: 80
Pod를 생성합니다.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create -f pod.yaml
$ oc create -f pod.yaml
생성 후 Pod 사양을 확인합니다.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pod website -o yaml
$ oc get pod website -o yaml apiVersion: v1 kind: Pod metadata: name: website labels: app: website role: frontend annotations: podpreset.admission.kubernetes.io/allow-database: "resource version"
1 spec: containers: - name: website image: ecorp/website volumeMounts:
2 - mountPath: /cache name: cache-volume ports: - containerPort: 80 env:
3 - name: DB_PORT value: "6379" volumes: - name: cache-volume emptyDir: {}