OpenShift leverages the kubernetes concept of a
pod, defined as "one or more containers deployed together on one host, & the smallest compute unit that can be defined, deployed, & managed."
Pods are the rough equivalent of a machine instance (physical or virtual) to a container, wherein each pod is allocated its own internal IP address, therefore owning its entire port space, and containers within pods can share their local storage and networking.
openshift treats pods as largely immutable; changes cannot be made to a pod definition while it is running. openshift implements changes by terminating an existing pod and recreating it with modified configuration, base image(s), or both. Pods are also treated as expendable, and do not maintain state when recreated. Therefore pods should usually be managed by higher-level controllers, rather than directly by users.
apiVersion: v1 kind: Pod metadata: name: mysql (1) labels: (2) name: mysql spec: containers: (3) - resources: limits : cpu: 0.5 image: openshift/mysql-55-centos7 (5) name: mysql env: (4) - name: MYSQL_ROOT_PASSWORD value: yourpassword - name: MYSQL_USER value: wp_user - name: MYSQL_PASSWORD value: wp_pass - name: MYSQL_DATABASE value: wp_db ports: (6) - containerPort: 3306 name: mysql volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql/data volumes: (7) - name: mysql-persistent-storage persistentVolumeClaim: claimName: claim-mysql
namewithin their namespace. As a note, a pod definition may specify the basis of a name with the
generateNameattribute, and random characters will be added automatically to generate a unique name.
labels, which can then be used to select and manage groups of pods in a single operation. The labels are stored in key/value format in the metadata hash. In the example, our pod is simply labeled as
containersspecifies an array of container definitions.
(env:)can be specified to pass necessary values to each container.
portswhich will be made available on the pod’s IP.
volumesthat are available to its container(s) to use. In this case, it provides an
mysql-persistent-storage, with a specific
mountPath:in the container on