From Image
$ oc new-project myproj01
$ oc new-app --name=httpd-24 --image=registry.access.redhat.com/ubi8/httpd-24 --labels app=httpd-24
$ oc get all
$ oc logs pod/httpd-24-9fb54567d-n9slj
$ oc expose service/httpd-24
$ oc get all
$ curl http://httpd-24-ch06s03.apps-crc.testing/
$ oc exec pod/httpd-24-9fb54567d-n9slj -- ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
1000650+ 1 0.0 0.2 391296 21980 ? Ss 19:54 0:00 httpd -D FOREGROUND
$ oc describe pod/httpd-24-9fb54567d-n9slj
Source-to-Image (S2I)
$ oc new-project myproj03
$ oc get is -n openshift
$ oc new-app --name=ruby-hello-world --labels app=myapp --image-stream=ruby https://github.com/openshift/ruby-hello-world
$ oc get all
$ oc logs -f pod/ruby-hello-world-1-build
$ oc describe pod/ruby-hello-world-1-build
$ oc describe service/ruby-hello-world
$ oc expose service/ruby-hello-world
$ curl http://ruby-hello-world-myproj03.apps-crc.testing/
$ oc get buildconfig
NAME TYPE FROM LATEST
ruby-hello-world Source Git 1
$ oc start-build ruby-hello-world
From Template
$ oc new-project myproj02
$ oc get templates -n openshift
$ oc get templates -n openshift | grep mysql
mysql-ephemeral MySQL database service, without persistent storage. For more information abou... 8 (3 generated) 3
mysql-persistent MySQL database service, with persistent storage. For more information about u... 9 (3 generated) 4
$ oc describe template mysql-persistent -n openshift
$ oc new-app --name=app-db --template=mysql-persistent \
--param MYSQL_USER=myuser \
--param MYSQL_PASSWORD=redhat123 \
--param MYSQL_ROOT_PASSWORD=redhat123 \
--param MYSQL_DATABASE=items \
--labels app=app-db
$ oc get events
$ oc describe service/mysql
Name: mysql
Namespace: myproj02
Labels: app=app-db
template=mysql-persistent-template
Annotations: openshift.io/generated-by: OpenShiftNewApp
template.openshift.io/expose-uri: mysql://{.spec.clusterIP}:{.spec.ports[?(.name=="mysql")].port}
Selector: name=mysql
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.217.4.67
IPs: 10.217.4.67
Port: mysql 3306/TCP
TargetPort: 3306/TCP
Endpoints: 10.217.0.106:3306
Session Affinity: None
Events: <none>
$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
mysql Bound pv0023 100Gi RWO,ROX,RWX 2m59s
$ oc describe pvc mysql
Name: mysql
Namespace: myproj02
StorageClass:
Status: Bound
Volume: pv0023
Labels: app=app-db
template=mysql-persistent-template
Annotations: openshift.io/generated-by: OpenShiftNewApp
pv.kubernetes.io/bind-completed: yes
pv.kubernetes.io/bound-by-controller: yes
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 100Gi
Access Modes: RWO,ROX,RWX
VolumeMode: Filesystem
Used By: mysql-1-qncwj
Events: <none>
$ oc port-forward pod/mysql-1-qncwj 3306:3306
$ mysql --host=127.0.0.1 --port=3306 --user=myuser --password=redhat123 --database=items --execute="show databases;"
No comments:
Post a Comment