An image stream is just a wrapper to the container image to allow more flexibility with tagging.
Use oc new-app very similarly to before using image streams.
Note:
- This example uses oc new-app commands. In practice (real life), use a Git repository with the -o yaml and create a deploymentimage.yaml manifest file, as it is declarative, repeatable, given versions, and inherently leads to IaC (Infrastructure as Code).
- An example of using -o yaml is below.
Create a New Application Deployment with an Image Stream:
a. Create app using oc new-app:
- Syntax:
$ oc new-app -i <image_stream_name> -e <variable>=<variable_value> -e <variable2>=<variable2_value> -e <variable3>=<variable3_value> -l <label_name>=<label_value> --name <app_name>
Notes:
-i = image stream
-e = variable(s)
-l = label
--name = different default name rather than the registry image or Git repository name
Example:
$ oc new-app \
-i mysql \
-e MYSQL_USER=user \
-e MYSQL_PASSWORD=mypassword\
-e MYSQL_DATABASE=testdb \
-l db=mysql
b. Expose the new app:
$ oc expose service <service_name>
Note:
- The service name depends on the app what it is called. Look at the Git or image repo documentation to determine the service name.
Delete an oc app:
Use the label to delete the deployment.
- Syntax:
$ oc delete all --selector app=<label_value>
Inspect Deployment (Dry Run):
To inspect, use the -o option and the rep URL:
- Syntax:
$ oc new-app -o yaml <repo_fqdn>/<project_name_or_user_id>/<project_image_name> > <deployment_filename.yaml>
Notes:
- The deployment has same BuildConfig, Deployment, Service, and metadata, but now includes an ImageStream section/kind, as well.
- The redirect output to file, e.g. > deploymentimage.yaml. allows testing versions and use of oc describe to review parts of the deployment
$ oc describe ...
$ cat deploymentimage.yaml
apiVersion: v1
items:
- apiVersion: image.openshift.io/v1
kind: ImageStream
...
- apiVersion: build.openshift.io/v1
kind: BuildConfig
...
- apiVersion: apps/v1
kind: Deployment
...
- apiVersion: v1
kind: Service
...
kind: List
metadata: {}
previous page
|