Sei sulla pagina 1di 3

Comparison of Stand-Alone Containerized App vs Clustered Containerized App with OpenShift

Stand Alone Containerized MariaDB Clustered Containerized MariaDB with OpenShift

1. Create PersistentVolume 2. Create PersistentVolumeClaim


1. Create OS Path for Persistent Volume
$ vi pv-mariadb.yaml $ vi pvc-mariadb.yaml api
# mkdir /root/var/lib/mysql apiVersion: v1 version: v1
# mount /dev/sdd /root/var/lib/mysql kind: PersistentVolume kind: PersistentVolumeClaim
metadata: metadata:
or name: mariadb-wp-volume name: mariadb-wp-claim
1. Create Docker Persistent Volume Resource spec: labels:
accessModes: name: wordpress
$ docker volume create mariadb-vol - ReadWriteMany spec:
capacity: accessModes:
storage: 3Gi - ReadWriteMany
persistentVolumeReclaimPolicy: Recycle resources:
nfs: requests:
path: /exports/mariadb-wp storage: 3Gi
server: services.lab.example.com
$ oc create -f pvc-mariadb.yaml
$ oc create -f pv-mariadb.yaml

2. Use Virtual Network (Software Defined Network)

docker network create --attachable mariadb-privnet

3. Run MariaDB Container 3. Run oc new-app

$ docker container run -d --name wordpressdb \ $ oc new-app --name wordpressdb \

-e MYSQL_ROOT_PASSWORD='redhat' \ -e MYSQL_ROOT_PASSWORD=’redhat’ \
-e MYSQL_DATABASE='wordpress' \ -e MYSQL_DATABASE=’wordpress’ \
-e MYSQL_USER='wordpress' \ -e MYSQL_USER=’wordpress’ \
-e MYSQL_PASSWORD='redhat' \
-e MYSQL_PASSWORD=’redhat’ \
-v /root/var/lib/mysql:/var/lib/mysql \
-v mariadb-vol:/var/lib/mysql \ docker.io/mariadb:latest

--network mariadb-privnet \ 4. Run oc expose


$ oc expose svc/mymariadb
-p 3306:3306

docker.io/mariadb:latest

Service Route

- apiVersion: v1 - apiVersion: v1
kind: Service kind: Route
metadata: metadata:
annotations: annotations:
openshift.io/generated-by:… openshift.io/host.generated: "true"
creationTimestamp: null creationTimestamp: null
labels: labels:
app: mymariadb app: mymariadb
name: mymariadb name: mymariadb
spec: spec:
ports: host: mymariadb-docker-mariadb.router.default.svc.cluster.local
- name: 3306-tcp port:
port: 3306 targetPort: 3306-tcp
protocol: TCP to:
targetPort: 3306 kind: Service
selector: name: mymariadb
app: mymariadb weight: 100
deploymentconfig: mymariadb wildcardPolicy: None
sessionAffinity: None status:
type: ClusterIP ingress:
status: - conditions:
loadBalancer: {} - lastTransitionTime: "2020-05-07T23:57:55Z"
status: "True"
type: Admitted
host: mymariadb-docker-mariadb.router.default.svc.cluster.local
routerName: router
wildcardPolicy: None
Other Resources created by oc new-app

ImageStream ReplicationController Pod


apiVersion: v1 - apiVersion: v1 - apiVersion: v1
kind: ImageStream kind: ReplicationController kind: Pod
metadata: metadata: metadata:
annotations: annotations: annotations:
openshift.io/generated-by: OpenShiftNewApp openshift.io/deployer-pod.completed-at: … openshift.io/deployment-config.latest-version: "1"
openshift.io/image.dockerRepositoryCheck: … openshift.io/deployer-pod.created-at: … creationTimestamp: null
creationTimestamp: null openshift.io/deployer-pod.name: mymariadb-1-deploy generateName: mymariadb-1-
generation: 2 openshift.io/deployment-config.latest-version: "1" labels:
labels: openshift.io/deployment-config.name: mymariadb app: mymariadb
app: mymariadb openshift.io/deployment.phase: Complete deployment: mymariadb-1
name: mymariadb openshift.io/deployment.replicas: "1" deploymentconfig: mymariadb
spec: openshift.io/deployment.status-reason: config change ownerReferences:
lookupPolicy: openshift.io/encoded-deployment-config: | - apiVersion: v1
local: false …. blockOwnerDeletion: true
tags: creationTimestamp: null controller: true
- annotations: generation: 1 kind: ReplicationController
openshift.io/imported-from: labels: name: mymariadb-1
docker.io/mariadb:latest app: mymariadb uid: d3018abd-90bd-11ea-b78b-5254002f43ae
from: openshift.io/deployment-config.name: mymariadb spec:
kind: DockerImage name: mymariadb-1 containers:
name: docker-registry.default.svc:5000/docker- ownerReferences: - env:
mariadb/mymariadb:latest - apiVersion: apps.openshift.io/v1 - name: MYSQL_DATABASE
generation: 2 blockOwnerDeletion: true value: wordpress
importPolicy: {} controller: true - name: MYSQL_PASSWORD
name: latest kind: DeploymentConfig value: redhat
referencePolicy: name: mymariadb - name: MYSQL_ROOT_PASSWORD
type: Source uid: d243b370-90bd-11ea-b78b-5254002f43ae value: redhat
status: spec: - name: MYSQL_USER
dockerImageRepository: "" replicas: 1 value: wordpress
selector: image: docker.io/mariadb@sha2190aa60d14cc91d7bdcd983009faf8
app: mymariadb imagePullPolicy: Always
deployment: mymariadb-1 name: mymariadb
DeploymentConfig deploymentconfig: mymariadb ports:
template: - containerPort: 3306
- apiVersion: v1 metadata: protocol: TCP
kind: DeploymentConfig annotations: resources: {}
metadata: openshift.io/deployment-config.latest-version: "1" securityContext:
annotations: openshift.io/deployment-config.name: mymariadb capabilities:
openshift.io/generated-by: OpenShiftNewApp openshift.io/deployment.name: mymariadb-1 drop:
generation: 1 openshift.io/generated-by: OpenShiftNewApp - KILL
labels: creationTimestamp: null - MKNOD
app: mymariadb labels: - SETGID
name: mymariadb app: mymariadb - SETUID
spec: deployment: mymariadb-1 runAsUser: 1000160000
replicas: 1 deploymentconfig: mymariadb terminationMessagePath: /dev/termination-log
revisionHistoryLimit: 10 spec: terminationMessagePolicy: File
selector: containers: volumeMounts:
app: mymariadb - env: - mountPath: /var/lib/mysql
deploymentconfig: mymariadb - name: MYSQL_DATABASE name: mymariadb-volume-1
strategy: value: wordpress - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
activeDeadlineSeconds: 21600 - name: MYSQL_PASSWORD name: default-token-pqwqk
resources: {} value: redhat readOnly: true
rollingParams: - name: MYSQL_ROOT_PASSWORD dnsPolicy: ClusterFirst
intervalSeconds: 1 value: redhat imagePullSecrets:
maxSurge: 25% - name: MYSQL_USER - name: default-dockercfg-z66m6
maxUnavailable: 25% value: wordpress nodeName: student51-master.lab.example.com
timeoutSeconds: 600 image: docker.io/mariadb@sha256:9727537826a818e5cb nodeSelector:
updatePeriodSeconds: 1 imagePullPolicy: Always node-role.kubernetes.io/compute: "true"
type: Rolling name: mymariadb restartPolicy: Always
template: ports: schedulerName: default-scheduler
metadata: - containerPort: 3306 securityContext:
annotations: protocol: TCP fsGroup: 1000160000
openshift.io/generated-by: OpenShiftNewApp resources: {} seLinuxOptions:
creationTimestamp: null terminationMessagePath: /dev/termination-log level: s0:c13,c2
labels: terminationMessagePolicy: File serviceAccount: default
app: mymariadb volumeMounts: serviceAccountName: default
deploymentconfig: mymariadb - mountPath: /var/lib/mysql terminationGracePeriodSeconds: 30
spec: name: mymariadb-volume-1 volumes:
containers: dnsPolicy: ClusterFirst - emptyDir: {}
- env: restartPolicy: Always name: mymariadb-volume-1
- name: MYSQL_DATABASE schedulerName: default-scheduler - name: default-token-pqwqk
value: wordpress securityContext: {} secret:
- name: MYSQL_PASSWORD terminationGracePeriodSeconds: 30 defaultMode: 420
value: redhat volumes: secretName: default-token-pqwqk
- name: MYSQL_ROOT_PASSWORD - emptyDir: {} status:
value: redhat name: mymariadb-volume-1 phase: Pending
- name: MYSQL_USER status: qosClass: BestEffort
value: wordpress replicas: 0
image: docker.io/mariadb@sha256:a818b26d8131199f092e5cb
imagePullPolicy: Always
name: mymariadb
ports:
- containerPort: 3306
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/mysql
name: mymariadb-volume-1
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: mymariadb-volume-1
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- mymariadb
from:
kind: ImageStreamTag
name: mymariadb:latest
namespace: docker-mariadb
type: ImageChange
status:
availableReplicas: 0
latestVersion: 0
observedGeneration: 0
replicas: 0
unavailableReplicas: 0
updatedReplicas: 0
Additional Resources for Building Application with S2I

BuildConfig Build
- apiVersion: v1 - apiVersion: v1
kind: BuildConfig kind: Build
metadata: metadata:
annotations: annotations:
openshift.io/generated-by: OpenShiftNewApp openshift.io/build-config.name: php-helloworld
creationTimestamp: null openshift.io/build.number: "1"
labels: openshift.io/build.pod-name: php-helloworld-1-build
app: php-helloworld creationTimestamp: null
name: php-helloworld labels:
spec: app: php-helloworld
failedBuildsHistoryLimit: 5 buildconfig: php-helloworld
nodeSelector: null openshift.io/build-config.name: php-helloworld
output: openshift.io/build.start-policy: Serial
to: name: php-helloworld-1
kind: ImageStreamTag ownerReferences:
name: php-helloworld:latest - apiVersion: build.openshift.io/v1
postCommit: {} controller: true
resources: {} kind: BuildConfig
runPolicy: Serial name: php-helloworld
source: uid: 80c2938b-9061-11ea-b78b-5254002f43ae
git: spec:
uri: https://github.com/furqanpr/php-helloworld.git nodeSelector: null
type: Git output:
strategy: pushSecret:
sourceStrategy: name: builder-dockercfg-vdqtb
from: to:
kind: ImageStreamTag kind: ImageStreamTag
name: php:7.1 name: php-helloworld:latest
namespace: openshift postCommit: {}
type: Source resources: {}
successfulBuildsHistoryLimit: 5 revision:
triggers: git:
- github: author:
secret: f8lsLVnZZnQB8aC9usQE email: 46949889+furqanpr@users.noreply.github.com
type: GitHub name: furqanpr
- generic: commit: f13fa001fb83f13df9b4aa4b3a8f9c5ad48b511c
secret: T593WknjrYk9WCdFFBDl committer:
type: Generic email: noreply@github.com
- type: ConfigChange name: GitHub
- imageChange: {} message: Create index.php
type: ImageChange type: Git
status: serviceAccount: builder
lastVersion: 0 source:
git:
uri: https://github.com/furqanpr/php-helloworld.git
type: Git
strategy:
sourceStrategy:
from:
kind: DockerImage
name: registry.access.redhat.com/rhscl/php-71-rhel7@sha256:289ef5852151a1a3ea4fdf2581a86e6d2b8d
type: Source
triggeredBy:
- imageChangeBuild:
fromRef:
kind: ImageStreamTag
name: php:7.1
namespace: openshift
imageID: registry.access.redhat.com/rhscl/php-71-rhel7@sha256:289ef5852151a1a3ea4fdf2581a86a60ada07
message: Image change
status:
config:
name: php-helloworld
output:
to:
imageDigest: sha256:63349d9891fbb522d9fe500e2043acc3a31c428c9de44f3acbd7b63ac7ea13e6
outputDockerImageReference: docker-registry.default.svc:5000/php-helloworld/php-helloworld:latest
phase: New
stages:
- durationMilliseconds: 1619
name: FetchInputs
startTime: "2020-05-07T12:51:51Z"
steps:
- durationMilliseconds: 1619
name: FetchGitSource
startTime: "2020-05-07T12:51:51Z"
- durationMilliseconds: 733
name: CommitContainer
startTime: "2020-05-07T12:53:23Z"
steps:
- durationMilliseconds: 733
name: CommitContainer
startTime: "2020-05-07T12:53:23Z"
- durationMilliseconds: 6579
name: Assemble
startTime: "2020-05-07T12:53:18Z"
steps:
- durationMilliseconds: 6579
name: AssembleBuildScripts
startTime: "2020-05-07T12:53:18Z"
- durationMilliseconds: 95462
name: PushImage
startTime: "2020-05-07T12:53:24Z"
steps:
- durationMilliseconds: 95462
name: PushImage
startTime: "2020-05-07T12:53:24Z"

Potrebbero piacerti anche