CLI tools OpenShift Container Platform 4.7 Learning how to use the command-line tools for OpenShift Container Platform Red Hat OpenShift Documentation Team

Commands:
tar xvzf <file>
echo USDPATH
oc <command>
C:\> path
C:\> oc <command>
echo USDPATH
oc <command>
tar xvzf <file>
echo USDPATH
oc <command>
C:\> path
C:\> oc <command>
echo USDPATH
oc <command>
subscription-manager register
subscription-manager refresh
subscription-manager list --available --matches '*OpenShift*'
subscription-manager attach --pool=<pool_id>
subscription-manager repos --enable="rhocp-4.7-for-rhel-8-x86_64-rpms"
subscription-manager repos --enable="rhel-7-server-ose-4.7-rpms"
yum install openshift-clients
oc <command>
brew install openshift-cli
oc login -u user1
Server [https://localhost:8443]: https://openshift.example.com:6443 1 The server uses a certificate signed by an unknown authority. You can bypass the certificate check, but any data you send to the server could be intercepted by others. Use insecure connections? (y/n): y 2 Authentication required for https://openshift.example.com:6443 (openshift) Username: user1 Password: 3 Login successful. You don't have any projects. You can try to create a new project, by running oc new-project <projectname> Welcome! See 'oc help' to get started.
oc new-project my-project
Now using project "my-project" on server "https://openshift.example.com:6443".
oc new-app https://github.com/sclorg/cakephp-ex
--> Found image 40de956 (9 days old) in imagestream "openshift/php" under tag "7.2" for "php" Run 'oc status' to view your app.
oc get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE cakephp-ex-1-build 0/1 Completed 0 5m45s 10.131.0.10 ip-10-0-141-74.ec2.internal <none> cakephp-ex-1-deploy 0/1 Completed 0 3m44s 10.129.2.9 ip-10-0-147-65.ec2.internal <none> cakephp-ex-1-ktz97 1/1 Running 0 3m33s 10.128.2.11 ip-10-0-168-105.ec2.internal <none>
oc logs cakephp-ex-1-deploy
--> Scaling cakephp-ex-1 to 1 --> Success
oc project
Using project "my-project" on server "https://openshift.example.com:6443".
oc status
In project my-project on server https://openshift.example.com:6443 svc/cakephp-ex - 172.30.236.80 ports 8080, 8443 dc/cakephp-ex deploys istag/cakephp-ex:latest <- bc/cakephp-ex source builds https://github.com/sclorg/cakephp-ex on openshift/php:7.2 deployment #1 deployed 2 minutes ago - 1 pod 3 infos identified, use 'oc status --suggest' to see details.
oc api-resources
NAME SHORTNAMES APIGROUP NAMESPACED KIND bindings true Binding componentstatuses cs false ComponentStatus configmaps cm true ConfigMap
oc help
OpenShift Client This client helps you develop, build, deploy, and run your applications on any OpenShift or Kubernetes compatible platform. It also includes the administrative commands for managing a cluster under the 'adm' subcommand. Usage: oc [flags] Basic Commands: login Log in to a server new-project Request a new project new-app Create a new application
oc create --help
Create a resource by filename or stdin JSON and YAML formats are accepted. Usage: oc create -f FILENAME [flags]
oc explain pods
KIND: Pod VERSION: v1 DESCRIPTION: Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts. FIELDS: apiVersion <string> APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
oc logout
Logged "user1" out on "https://openshift.example.com"
oc completion bash > oc_bash_completion
sudo cp oc_bash_completion /etc/bash_completion.d/
cat >>~/.zshrc<<EOF if [ USDcommands[oc] ]; then source <(oc completion zsh) compdef _oc oc fi EOF
apiVersion: v1 clusters: 1 - cluster: insecure-skip-tls-verify: true server: https://openshift1.example.com:8443 name: openshift1.example.com:8443 - cluster: insecure-skip-tls-verify: true server: https://openshift2.example.com:8443 name: openshift2.example.com:8443 contexts: 2 - context: cluster: openshift1.example.com:8443 namespace: alice-project user: alice/openshift1.example.com:8443 name: alice-project/openshift1.example.com:8443/alice - context: cluster: openshift1.example.com:8443 namespace: joe-project user: alice/openshift1.example.com:8443 name: joe-project/openshift1/alice current-context: joe-project/openshift1.example.com:8443/alice 3 kind: Config preferences: {} users: 4 - name: alice/openshift1.example.com:8443 user: token: xZHd2piv5_9vQrg-SKXRJ2Dsl9SceNJdhNTljEKTb8k
oc status
status In project Joe's Project (joe-project) service database (172.30.43.12:5434 -> 3306) database deploys docker.io/openshift/mysql-55-centos7:latest #1 deployed 25 minutes ago - 1 pod service frontend (172.30.159.137:5432 -> 8080) frontend deploys origin-ruby-sample:latest <- builds https://github.com/openshift/ruby-hello-world with joe-project/ruby-20-centos7:latest #1 deployed 22 minutes ago - 2 pods To see more information about a service or deployment, use 'oc describe service <name>' or 'oc describe dc <name>'. You can use 'oc get all' to see lists of each of the types described in this example.
oc project
Using project "joe-project" from context named "joe-project/openshift1.example.com:8443/alice" on server "https://openshift1.example.com:8443".
oc project alice-project
Now using project "alice-project" on server "https://openshift1.example.com:8443".
oc login -u system:admin -n default
oc config set-cluster <cluster_nickname> [--server=<master_ip_or_fqdn>] [--certificate-authority=<path/to/certificate/authority>] [--api-version=<apiversion>] [--insecure-skip-tls-verify=true]
oc config set-context <context_nickname> [--cluster=<cluster_nickname>] [--user=<user_nickname>] [--namespace=<namespace>]
oc config use-context <context_nickname>
oc config set <property_name> <property_value>
oc config unset <property_name>
oc config view
oc config view --config=<specific_filename>
oc login https://openshift1.example.com --token=ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0
oc config view
apiVersion: v1 clusters: - cluster: insecure-skip-tls-verify: true server: https://openshift1.example.com name: openshift1-example-com contexts: - context: cluster: openshift1-example-com namespace: default user: alice/openshift1-example-com name: default/openshift1-example-com/alice current-context: default/openshift1-example-com/alice kind: Config preferences: {} users: - name: alice/openshift1.example.com user: token: ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0
oc config set-context `oc config current-context` --namespace=<project_name>
oc whoami -c
#!/bin/bash optional argument handling if [[ "USD1" == "version" ]] then echo "1.0.0" exit 0 fi optional argument handling if [[ "USD1" == "config" ]] then echo USDKUBECONFIG exit 0 fi echo "I am a plugin named kubectl-foo"
chmod +x <plugin_file>
sudo mv <plugin_file> /usr/local/bin/.
oc plugin list
The following compatible plugins are available: /usr/local/bin/<plugin_file>
oc ns
oc explain pods
oc login -u user1
oc new-app .
oc new-app https://github.com/sclorg/cakephp-ex
oc new-app https://github.com/youruser/yourprivaterepo --source-secret=yoursecret
oc new-project myproject
oc project test-project
oc projects
oc status
oc cancel-build python-1
oc cancel-build buildconfig/python --state=pending
oc import-image my-ruby
oc new-build .
oc new-build https://github.com/sclorg/cakephp-ex
oc rollback php
oc rollback php --to-version=3
oc rollout undo deploymentconfig/php
oc rollout latest deploymentconfig/php
oc start-build python
oc start-build --from-build=python-1
oc start-build python --env=mykey=myvalue
oc tag ruby:latest ruby:2.0
oc annotate route/test-route haproxy.router.openshift.io/ip_whitelist="192.168.1.10"
oc annotate route/test-route haproxy.router.openshift.io/ip_whitelist-
oc apply -f pod.json
oc autoscale deploymentconfig/parksmap-katacoda --min=2 --max=5
oc create -f pod.json
oc delete pod/parksmap-katacoda-1-qfqz4
oc delete pods -l app=parksmap-katacoda
oc describe deployment/example
oc describe pods
oc edit deploymentconfig/parksmap-katacoda
OC_EDITOR="nano" oc edit deploymentconfig/parksmap-katacoda
oc edit deploymentconfig/parksmap-katacoda -o json
oc expose service/parksmap-katacoda
oc expose service/parksmap-katacoda --hostname=www.my-host.com
oc get pods -n default
oc get deploymentconfig/python -o json
oc label pod/python-1-mz2rf status=unhealthy
oc scale deploymentconfig/ruby-app --replicas=3
oc secrets link default my-pull-secret --for=pull
oc serviceaccounts get-token default
oc set build-secret --source buildconfig/mybc mysecret
oc attach python-1-mz2rf -c python
oc cp default/python-1-mz2rf:/opt/app-root/src/README.md ~/mydirectory/.
oc debug deploymentconfig/python
oc exec python-1-mz2rf -c python ls
oc logs -f deploymentconfig/python
oc port-forward python-1-mz2rf 8888:5000
oc proxy --port=8011 --www=./local/www/
oc rsh python-1-mz2rf
oc rsync ~/mydirectory/ python-1-mz2rf:/opt/app-root/src/
oc run my-test --image=perl
oc wait --for=delete pod/python-1-mz2rf
oc api-resources
oc api-versions
oc auth can-i get pods --subresource=log
oc auth reconcile -f policy.json
oc cluster-info
oc extract configmap/ruby-1-ca
oc extract configmap/ruby-1-ca --to=-
oc idle ruby-app
oc image mirror myregistry.com/myimage:latest myregistry.com/myimage:stable
oc observe services
oc patch node/node1 -p '{"spec":{"unschedulable":true}}'
oc policy add-role-to-user edit user1
oc process -f template.json | oc create -f -
oc registry info
oc replace -f pod.json
oc completion bash
oc config view
oc config use-context test-context
oc logout
oc whoami
oc help
oc help new-project
oc plugin list
oc version
oc adm inspect clusteroperator/openshift-apiserver
oc adm must-gather
oc adm top pods
oc adm top images
oc adm cordon node1
oc adm drain node1
oc adm node-logs --role master -u NetworkManager.service
oc adm taint nodes node1 dedicated=groupName:NoSchedule
oc adm taint nodes node1 dedicated-
oc adm uncordon node1
oc adm certificate approve csr-sqgzp
oc adm groups new my-group
oc adm new-project myproject --node-selector='type=user-node,region=east'
oc adm pod-network isolate-projects project1 project2
oc adm policy add-cluster-role-to-user edit user1
oc adm policy add-scc-to-user privileged -z myserviceaccount
oc adm migrate storage
oc adm migrate storage --include=pods
oc adm prune builds --orphans
oc adm create-bootstrap-project-template -o yaml
oc adm create-error-template
oc adm create-kubeconfig --client-certificate=/path/to/client.crt --client-key=/path/to/client.key --certificate-authority=/path/to/ca.crt
oc adm create-login-template
oc adm create-provider-selection-template
oc adm build-chain perl
oc adm completion bash
oc adm config view
oc adm config use-context test-context
oc adm release info --changelog=/tmp/git quay.io/openshift-release-dev/ocp-release:4.7.0-x86_64 quay.io/openshift-release-dev/ocp-release:4.7.1-x86_64 > changelog.md
oc adm verify-image-signature sha256:2bba968aedb7dd2aafe5fa8c7453f5ac36a0b9639f1bf5b03f95de325238b288 --expected-identity 172.30.1.1:5000/openshift/nodejs:latest --public-key /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release --save
odo delete --deploy
odo login -u developer -p developer
odo catalog list components
Odo Devfile Components: NAME DESCRIPTION REGISTRY dotnet50 Stack with .NET 5.0 DefaultDevfileRegistry dotnet60 Stack with .NET 6.0 DefaultDevfileRegistry dotnetcore31 Stack with .NET Core 3.1 DefaultDevfileRegistry go Stack with the latest Go version DefaultDevfileRegistry java-maven Upstream Maven and OpenJDK 11 DefaultDevfileRegistry java-openliberty Java application Maven-built stack using the Open Liberty ru... DefaultDevfileRegistry java-openliberty-gradle Java application Gradle-built stack using the Open Liberty r... DefaultDevfileRegistry java-quarkus Quarkus with Java DefaultDevfileRegistry java-springboot Spring Boot(R) using Java DefaultDevfileRegistry java-vertx Upstream Vert.x using Java DefaultDevfileRegistry java-websphereliberty Java application Maven-built stack using the WebSphere Liber... DefaultDevfileRegistry java-websphereliberty-gradle Java application Gradle-built stack using the WebSphere Libe... DefaultDevfileRegistry java-wildfly Upstream WildFly DefaultDevfileRegistry java-wildfly-bootable-jar Java stack with WildFly in bootable Jar mode, OpenJDK 11 and... DefaultDevfileRegistry nodejs Stack with Node.js 14 DefaultDevfileRegistry nodejs-angular Stack with Angular 12 DefaultDevfileRegistry nodejs-nextjs Stack with Next.js 11 DefaultDevfileRegistry nodejs-nuxtjs Stack with Nuxt.js 2 DefaultDevfileRegistry nodejs-react Stack with React 17 DefaultDevfileRegistry nodejs-svelte Stack with Svelte 3 DefaultDevfileRegistry nodejs-vue Stack with Vue 3 DefaultDevfileRegistry php-laravel Stack with Laravel 8 DefaultDevfileRegistry python Python Stack with Python 3.7 DefaultDevfileRegistry python-django Python3.7 with Django DefaultDevfileRegistry
curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-linux-amd64 -o odo
curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-linux-amd64.tar.gz -o odo.tar.gz tar xvzf odo.tar.gz
chmod +x <filename>
echo USDPATH
odo version
C:\> path
C:\> odo version
curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-darwin-amd64 -o odo
curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-darwin-amd64.tar.gz -o odo.tar.gz tar xvzf odo.tar.gz
chmod +x odo
echo USDPATH
odo version
ext install redhat.vscode-openshift-connector
subscription-manager register
subscription-manager refresh
subscription-manager list --available --matches '*OpenShift Developer Tools and Services*'
subscription-manager attach --pool=<pool_id>
subscription-manager repos --enable="ocp-tools-4.9-for-rhel-8-x86_64-rpms"
yum install odo
odo version
odo preference view
PARAMETER CURRENT_VALUE UpdateNotification NamePrefix Timeout BuildTimeout PushTimeout Ephemeral ConsentTelemetry true
odo preference set <key> <value>
odo preference set updatenotification false
Global preference was successfully updated
odo preference unset <key>
odo preference unset updatenotification ? Do you want to unset updatenotification in the preference (y/N) y
Global preference was successfully updated
.git *.js tests/
components: - image: imageName: quay.io/myusername/myimage dockerfile: uri: ./Dockerfile <.> buildContext: USD{PROJECTS_ROOT} <.> name: component-built-from-dockerfile
odo catalog list components
NAME DESCRIPTION REGISTRY go Stack with the latest Go version DefaultDevfileRegistry java-maven Upstream Maven and OpenJDK 11 DefaultDevfileRegistry nodejs Stack with Node.js 14 DefaultDevfileRegistry php-laravel Stack with Laravel 8 DefaultDevfileRegistry python Python Stack with Python 3.7 DefaultDevfileRegistry [...]
odo catalog describe component
odo catalog describe component nodejs
* Registry: DefaultDevfileRegistry <.> Starter Projects: <.> --- name: nodejs-starter attributes: {} description: "" subdir: "" projectsource: sourcetype: "" git: gitlikeprojectsource: commonprojectsource: {} checkoutfrom: null remotes: origin: https://github.com/odo-devfiles/nodejs-ex.git zip: null custom: null
odo catalog list services
Services available through Operators NAME CRDs postgresql-operator.v0.1.1 Backup, Database redis-operator.v0.8.0 RedisCluster, Redis
odo catalog search service
odo catalog search service postgres
Services available through Operators NAME CRDs postgresql-operator.v0.1.1 Backup, Database
odo catalog describe service
odo catalog describe service postgresql-operator.v0.1.1/Database
KIND: Database VERSION: v1alpha1 DESCRIPTION: Database is the Schema for the the Database Database API FIELDS: awsAccessKeyId (string) AWS S3 accessKey/token ID Key ID of AWS S3 storage. Default Value: nil Required to create the Secret with the data to allow send the backup files to AWS S3 storage. [...]
odo catalog describe service redis-operator.v0.8.0
NAME: redis-operator.v0.8.0 DESCRIPTION: A Golang based redis operator that will make/oversee Redis standalone/cluster mode setup on top of the Kubernetes. It can create a redis cluster setup with best practices on Cloud as well as the Bare metal environment. Also, it provides an in-built monitoring capability using ... (cut short for beverity) Logging Operator is licensed under [Apache License, Version 2.0](https://github.com/OT-CONTAINER-KIT/redis-operator/blob/master/LICENSE) CRDs: NAME DESCRIPTION RedisCluster Redis Cluster Redis Redis
odo create nodejs mynodejs
odo create nodejs mynodejs --context ./node-backend
odo create nodejs --app myapp --project backend
odo catalog describe component nodejs
odo create nodejs --starter nodejs-starter
odo create mynodejs --devfile https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml
odo create ? Which devfile component type do you wish to create go ? What do you wish to name the new devfile component go-api ? What project do you want the devfile component to be created in default Devfile Object Validation [✓] Checking devfile existence [164258ns] [✓] Creating a devfile component from registry: DefaultDevfileRegistry [246051ns] Validation [✓] Validating if devfile name is correct [92255ns] ? Do you want to download a starter project Yes Starter Project [✓] Downloading starter project go-starter from https://github.com/devfile-samples/devfile-stack-go.git [429ms] Please use odo push command to create the component with source deployed
odo delete
odo delete --deploy
odo delete --all
schemaVersion: 2.2.0 [...] variables: CONTAINER_IMAGE: quay.io/phmartin/myimage commands: - id: build-image apply: component: outerloop-build - id: deployk8s apply: component: outerloop-deploy - id: deploy composite: commands: - build-image - deployk8s group: kind: deploy isDefault: true components: - name: outerloop-build image: imageName: "{{CONTAINER_IMAGE}}" dockerfile: uri: ./Dockerfile buildContext: USD{PROJECTS_ROOT} - name: outerloop-deploy kubernetes: inlined: | kind: Deployment apiVersion: apps/v1 metadata: name: my-component spec: replicas: 1 selector: matchLabels: app: node-app template: metadata: labels: app: node-app spec: containers: - name: main image: {{CONTAINER_IMAGE}}
odo list
APP NAME PROJECT TYPE STATE MANAGED BY ODO app backend myproject spring Pushed Yes
odo service list
NAME MANAGED BY ODO STATE AGE PostgresCluster/hippo Yes (backend) Pushed 59m41s
odo link PostgresCluster/hippo
[✓] Successfully created link between component "backend" and service "PostgresCluster/hippo" To apply the link, please use `odo push`
odo url list
Found the following URLs for component backend NAME STATE URL PORT SECURE KIND 8080-tcp Pushed http://8080-tcp.192.168.39.112.nip.io 8080 false ingress
odo describe
Component Name: backend Type: spring Environment Variables: · PROJECTS_ROOT=/projects · PROJECT_SOURCE=/projects · DEBUG_PORT=5858 Storage: · m2 of size 3Gi mounted to /home/user/.m2 URLs: · http://8080-tcp.192.168.39.112.nip.io exposed via 8080 Linked Services: · PostgresCluster/hippo Environment Variables: · POSTGRESCLUSTER_PGBOUNCER-EMPTY · POSTGRESCLUSTER_PGBOUNCER.INI · POSTGRESCLUSTER_ROOT.CRT · POSTGRESCLUSTER_VERIFIER · POSTGRESCLUSTER_ID_ECDSA · POSTGRESCLUSTER_PGBOUNCER-VERIFIER · POSTGRESCLUSTER_TLS.CRT · POSTGRESCLUSTER_PGBOUNCER-URI · POSTGRESCLUSTER_PATRONI.CRT-COMBINED · POSTGRESCLUSTER_USER · pgImage · pgVersion · POSTGRESCLUSTER_CLUSTERIP · POSTGRESCLUSTER_HOST · POSTGRESCLUSTER_PGBACKREST_REPO.CONF · POSTGRESCLUSTER_PGBOUNCER-USERS.TXT · POSTGRESCLUSTER_SSH_CONFIG · POSTGRESCLUSTER_TLS.KEY · POSTGRESCLUSTER_CONFIG-HASH · POSTGRESCLUSTER_PASSWORD · POSTGRESCLUSTER_PATRONI.CA-ROOTS · POSTGRESCLUSTER_DBNAME · POSTGRESCLUSTER_PGBOUNCER-PASSWORD · POSTGRESCLUSTER_SSHD_CONFIG · POSTGRESCLUSTER_PGBOUNCER-FRONTEND.KEY · POSTGRESCLUSTER_PGBACKREST_INSTANCE.CONF · POSTGRESCLUSTER_PGBOUNCER-FRONTEND.CA-ROOTS · POSTGRESCLUSTER_PGBOUNCER-HOST · POSTGRESCLUSTER_PORT · POSTGRESCLUSTER_ROOT.KEY · POSTGRESCLUSTER_SSH_KNOWN_HOSTS · POSTGRESCLUSTER_URI · POSTGRESCLUSTER_PATRONI.YAML · POSTGRESCLUSTER_DNS.CRT · POSTGRESCLUSTER_DNS.KEY · POSTGRESCLUSTER_ID_ECDSA.PUB · POSTGRESCLUSTER_PGBOUNCER-FRONTEND.CRT · POSTGRESCLUSTER_PGBOUNCER-PORT · POSTGRESCLUSTER_CA.CRT
ls kubernetes odo-service-backend-postgrescluster-hippo.yaml odo-service-hippo.yaml
odo unlink PostgresCluster/hippo
[✓] Successfully unlinked component "backend" from service "PostgresCluster/hippo" To apply the changes, please use `odo push`
ls kubernetes odo-service-hippo.yaml
odo link PostgresCluster/hippo --inlined
[✓] Successfully created link between component "backend" and service "PostgresCluster/hippo" To apply the link, please use `odo push`
kubernetes: inlined: | apiVersion: binding.operators.coreos.com/v1alpha1 kind: ServiceBinding metadata: creationTimestamp: null name: backend-postgrescluster-hippo spec: application: group: apps name: backend-app resource: deployments version: v1 bindAsFiles: false detectBindingResources: true services: - group: postgres-operator.crunchydata.com id: hippo kind: PostgresCluster name: hippo version: v1beta1 status: secret: "" name: backend-postgrescluster-hippo
odo link PostgresCluster/hippo --map pgVersion='{{ .hippo.spec.postgresVersion }}'
odo exec -- env | grep pgVersion
pgVersion=13
odo link PostgresCluster/hippo --map pgVersion='{{ .hippo.spec.postgresVersion }}' --map pgImage='{{ .hippo.spec.image }}'
odo exec -- env | grep -e "pgVersion\|pgImage"
pgVersion=13 pgImage=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.4-0
Linked Services: · PostgresCluster/hippo
odo unlink PostgresCluster/hippo odo push
odo link PostgresCluster/hippo --bind-as-files odo push
odo describe Component Name: backend Type: spring Environment Variables: · PROJECTS_ROOT=/projects · PROJECT_SOURCE=/projects · DEBUG_PORT=5858 · SERVICE_BINDING_ROOT=/bindings · SERVICE_BINDING_ROOT=/bindings Storage: · m2 of size 3Gi mounted to /home/user/.m2 URLs: · http://8080-tcp.192.168.39.112.nip.io exposed via 8080 Linked Services: · PostgresCluster/hippo Files: · /bindings/backend-postgrescluster-hippo/pgbackrest_instance.conf · /bindings/backend-postgrescluster-hippo/user · /bindings/backend-postgrescluster-hippo/ssh_known_hosts · /bindings/backend-postgrescluster-hippo/clusterIP · /bindings/backend-postgrescluster-hippo/password · /bindings/backend-postgrescluster-hippo/patroni.yaml · /bindings/backend-postgrescluster-hippo/pgbouncer-frontend.crt · /bindings/backend-postgrescluster-hippo/pgbouncer-host · /bindings/backend-postgrescluster-hippo/root.key · /bindings/backend-postgrescluster-hippo/pgbouncer-frontend.key · /bindings/backend-postgrescluster-hippo/pgbouncer.ini · /bindings/backend-postgrescluster-hippo/uri · /bindings/backend-postgrescluster-hippo/config-hash · /bindings/backend-postgrescluster-hippo/pgbouncer-empty · /bindings/backend-postgrescluster-hippo/port · /bindings/backend-postgrescluster-hippo/dns.crt · /bindings/backend-postgrescluster-hippo/pgbouncer-uri · /bindings/backend-postgrescluster-hippo/root.crt · /bindings/backend-postgrescluster-hippo/ssh_config · /bindings/backend-postgrescluster-hippo/dns.key · /bindings/backend-postgrescluster-hippo/host · /bindings/backend-postgrescluster-hippo/patroni.crt-combined · /bindings/backend-postgrescluster-hippo/pgbouncer-frontend.ca-roots · /bindings/backend-postgrescluster-hippo/tls.key · /bindings/backend-postgrescluster-hippo/verifier · /bindings/backend-postgrescluster-hippo/ca.crt · /bindings/backend-postgrescluster-hippo/dbname · /bindings/backend-postgrescluster-hippo/patroni.ca-roots · /bindings/backend-postgrescluster-hippo/pgbackrest_repo.conf · /bindings/backend-postgrescluster-hippo/pgbouncer-port · /bindings/backend-postgrescluster-hippo/pgbouncer-verifier · /bindings/backend-postgrescluster-hippo/id_ecdsa · /bindings/backend-postgrescluster-hippo/id_ecdsa.pub · /bindings/backend-postgrescluster-hippo/pgbouncer-password · /bindings/backend-postgrescluster-hippo/pgbouncer-users.txt · /bindings/backend-postgrescluster-hippo/sshd_config · /bindings/backend-postgrescluster-hippo/tls.crt
odo exec -- cat /bindings/backend-postgrescluster-hippo/password
q({JC:jn^mm/Bw}eu+j.GX{k
odo exec -- cat /bindings/backend-postgrescluster-hippo/user
hippo
odo exec -- cat /bindings/backend-postgrescluster-hippo/clusterIP
10.101.78.56
odo link PostgresCluster/hippo --map pgVersion='{{ .hippo.spec.postgresVersion }}' --map pgImage='{{ .hippo.spec.image }}' --bind-as-files odo push
odo exec -- cat /bindings/backend-postgrescluster-hippo/pgVersion
13
odo exec -- cat /bindings/backend-postgrescluster-hippo/pgImage
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.4-0
odo registry list
NAME URL SECURE DefaultDevfileRegistry https://registry.devfile.io No
odo registry add
odo registry add StageRegistry https://registry.stage.devfile.io New registry successfully added
odo registry add MyRegistry https://myregistry.example.com --token <access_token> New registry successfully added
odo registry delete
odo registry delete StageRegistry ? Are you sure you want to delete registry "StageRegistry" Yes Successfully deleted registry
odo registry update
odo registry update MyRegistry https://otherregistry.example.com --token <other_access_token> ? Are you sure you want to update registry "MyRegistry" Yes Successfully updated registry
odo service create
odo catalog list services Services available through Operators NAME CRDs redis-operator.v0.8.0 RedisCluster, Redis odo service create redis-operator.v0.8.0/Redis my-redis-service Successfully added service to the configuration; do 'odo push' to create service on the cluster
cat kubernetes/odo-service-my-redis-service.yaml
apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: Redis metadata: name: my-redis-service spec: kubernetesConfig: image: quay.io/opstree/redis:v6.2.5 imagePullPolicy: IfNotPresent resources: limits: cpu: 101m memory: 128Mi requests: cpu: 101m memory: 128Mi serviceType: ClusterIP redisExporter: enabled: false image: quay.io/opstree/redis-exporter:1.0 storage: volumeClaimTemplate: spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
cat devfile.yaml
[...] components: - kubernetes: uri: kubernetes/odo-service-my-redis-service.yaml name: my-redis-service [...]
odo service create redis-operator.v0.8.0/Redis
odo service create redis-operator.v0.8.0/Redis my-redis-service --inlined Successfully added service to the configuration; do 'odo push' to create service on the cluster
cat devfile.yaml
[...] components: - kubernetes: inlined: | apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: Redis metadata: name: my-redis-service spec: kubernetesConfig: image: quay.io/opstree/redis:v6.2.5 imagePullPolicy: IfNotPresent resources: limits: cpu: 101m memory: 128Mi requests: cpu: 101m memory: 128Mi serviceType: ClusterIP redisExporter: enabled: false image: quay.io/opstree/redis-exporter:1.0 storage: volumeClaimTemplate: spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi name: my-redis-service [...]
odo service create redis-operator.v0.8.0/Redis my-redis-service -p kubernetesConfig.image=quay.io/opstree/redis:v6.2.5 -p kubernetesConfig.serviceType=ClusterIP -p redisExporter.image=quay.io/opstree/redis-exporter:1.0 Successfully added service to the configuration; do 'odo push' to create service on the cluster
cat kubernetes/odo-service-my-redis-service.yaml
apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: Redis metadata: name: my-redis-service spec: kubernetesConfig: image: quay.io/opstree/redis:v6.2.5 serviceType: ClusterIP redisExporter: image: quay.io/opstree/redis-exporter:1.0
cat > my-redis.yaml <<EOF apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: Redis metadata: name: my-redis-service spec: kubernetesConfig: image: quay.io/opstree/redis:v6.2.5 serviceType: ClusterIP redisExporter: image: quay.io/opstree/redis-exporter:1.0 EOF
odo service create --from-file my-redis.yaml Successfully added service to the configuration; do 'odo push' to create service on the cluster
odo service delete
odo service list NAME MANAGED BY ODO STATE AGE Redis/my-redis-service Yes (api) Deleted locally 5m39s
odo service delete Redis/my-redis-service ? Are you sure you want to delete Redis/my-redis-service Yes Service "Redis/my-redis-service" has been successfully deleted; do 'odo push' to delete service from the cluster
odo service list
odo service list NAME MANAGED BY ODO STATE AGE Redis/my-redis-service-1 Yes (api) Not pushed Redis/my-redis-service-2 Yes (api) Pushed 52s Redis/my-redis-service-3 Yes (api) Deleted locally 1m22s
odo service describe
odo service describe Redis/my-redis-service Version: redis.redis.opstreelabs.in/v1beta1 Kind: Redis Name: my-redis-service Parameters: NAME VALUE kubernetesConfig.image quay.io/opstree/redis:v6.2.5 kubernetesConfig.serviceType ClusterIP redisExporter.image quay.io/opstree/redis-exporter:1.0
odo storage create
odo storage create store --path /data --size 1Gi [✓] Added storage store to nodejs-project-ufyy odo storage create tempdir --path /tmp --size 2Gi --ephemeral [✓] Added storage tempdir to nodejs-project-ufyy Please use `odo push` command to make the storage accessible to the component
odo storage list
odo storage list The component 'nodejs-project-ufyy' has the following storage attached: NAME SIZE PATH STATE store 1Gi /data Not Pushed tempdir 2Gi /tmp Not Pushed
odo storage delete
odo storage delete store -f Deleted storage store from nodejs-project-ufyy Please use `odo push` command to delete the storage from the cluster
components: - name: nodejs1 container: image: registry.access.redhat.com/ubi8/nodejs-12:1-36 memoryLimit: 1024Mi endpoints: - name: "3000-tcp" targetPort: 3000 mountSources: true - name: nodejs2 container: image: registry.access.redhat.com/ubi8/nodejs-12:1-36 memoryLimit: 1024Mi
odo storage create --container
odo storage create store --path /data --size 1Gi --container nodejs2 [✓] Added storage store to nodejs-testing-xnfg Please use `odo push` command to make the storage accessible to the component
odo storage list
The component 'nodejs-testing-xnfg' has the following storage attached: NAME SIZE PATH CONTAINER STATE store 1Gi /data nodejs2 Not Pushed
curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-amd64 -o /usr/local/bin/helm
chmod +x /usr/local/bin/helm
helm version
version.BuildInfo{Version:"v3.0", GitCommit:"b31719aab7963acf4887a1c1e6d5e53378e34d93", GitTreeState:"clean", GoVersion:"go1.13.4"}
curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-darwin-amd64 -o /usr/local/bin/helm
chmod +x /usr/local/bin/helm
helm version
version.BuildInfo{Version:"v3.0", GitCommit:"b31719aab7963acf4887a1c1e6d5e53378e34d93", GitTreeState:"clean", GoVersion:"go1.13.4"}
oc new-project mysql
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
"stable" has been added to your repositories
helm repo update
helm install example-mysql stable/mysql
helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION example-mysql mysql 1 2019-12-05 15:06:51.379134163 -0500 EST deployed mysql-1.5.0 5.7.27
oc new-project nodejs-ex-k
git clone https://github.com/redhat-developer/redhat-helm-charts
cd redhat-helm-charts/alpha/nodejs-ex-k/
apiVersion: v2 1 name: nodejs-ex-k 2 description: A Helm chart for OpenShift 3 icon: https://static.redhat.com/libs/redhat/brand-assets/latest/corp/logo.svg 4
helm lint
[INFO] Chart.yaml: icon is recommended 1 chart(s) linted, 0 chart(s) failed
cd ..
helm install nodejs-chart nodejs-ex-k
helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION nodejs-chart nodejs-ex-k 1 2019-12-05 15:06:51.379134163 -0500 EST deployed nodejs-0.1.0 1.16.0
apiVersion: helm.openshift.io/v1beta1 kind: HelmChartRepository metadata: name: <name> spec: # optional name that might be used by console # name: <chart-display-name> connectionConfig: url: <helm-chart-repository-url>
cat <<EOF | oc apply -f - apiVersion: helm.openshift.io/v1beta1 kind: HelmChartRepository metadata: name: azure-sample-repo spec: name: azure-sample-repo connectionConfig: url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs EOF
oc create configmap helm-ca-cert --from-file=ca-bundle.crt=/path/to/certs/ca.crt -n openshift-config
oc create secret generic helm-tls-configs --from-file=tls.crt=/path/to/certs/client.crt --from-file=tls.key=/path/to/certs//client.key -n openshift-config
cat <<EOF | oc apply -f - apiVersion: helm.openshift.io/v1beta1 kind: HelmChartRepository metadata: name: <helm-repository> spec: name: <helm-repository> connectionConfig: url: <URL for the Helm repository> tlsConfig: name: helm-tls-configs ca: name: helm-ca-cert EOF
cat <<EOF | kubectl apply -f - apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: openshift-config name: helm-chartrepos-tls-conf-viewer rules: - apiGroups: [""] resources: ["configmaps"] resourceNames: ["helm-ca-cert"] verbs: ["get"] - apiGroups: [""] resources: ["secrets"] resourceNames: ["helm-tls-configs"] verbs: ["get"] --- kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: openshift-config name: helm-chartrepos-tls-conf-viewer subjects: - kind: Group apiGroup: rbac.authorization.k8s.io name: 'system:authenticated' roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: helm-chartrepos-tls-conf-viewer EOF
cat <<EOF | oc apply -f - apiVersion: helm.openshift.io/v1beta1 kind: HelmChartRepository metadata: name: azure-sample-repo spec: connectionConfig: url:https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs disabled: true EOF
spec: connectionConfig: url: <url-of-the-repositoru-to-be-disabled> disabled: true
tar xvzf <file>
echo USDPATH
subscription-manager register
subscription-manager refresh
subscription-manager list --available --matches '*pipelines*'
subscription-manager attach --pool=<pool_id>
subscription-manager repos --enable="pipelines-1.4-for-rhel-8-x86_64-rpms"
subscription-manager repos --enable="pipelines-1.4-for-rhel-8-s390x-rpms"
subscription-manager repos --enable="pipelines-1.4-for-rhel-8-ppc64le-rpms"
yum install openshift-pipelines-client
tkn version
C:\> path
echo USDPATH
tkn completion bash > tkn_bash_completion
sudo cp tkn_bash_completion /etc/bash_completion.d/
tkn
tkn completion bash
tkn version
tkn pipeline --help
tkn pipeline delete mypipeline -n myspace
tkn pipeline describe mypipeline
tkn pipeline list
tkn pipeline logs -f mypipeline
tkn pipeline start mypipeline
tkn pipelinerun -h
tkn pipelinerun cancel mypipelinerun -n myspace
tkn pipelinerun delete mypipelinerun1 mypipelinerun2 -n myspace
tkn pipelinerun describe mypipelinerun -n myspace
tkn pipelinerun list -n myspace
tkn pipelinerun logs mypipelinerun -a -n myspace
tkn task -h
tkn task delete mytask1 mytask2 -n myspace
tkn task describe mytask -n myspace
tkn task list -n myspace
tkn task logs mytask mytaskrun -n myspace
tkn task start mytask -s <ServiceAccountName> -n myspace
tkn taskrun -h
tkn taskrun cancel mytaskrun -n myspace
tkn taskrun delete mytaskrun1 mytaskrun2 -n myspace
tkn taskrun describe mytaskrun -n myspace
tkn taskrun list -n myspace
tkn taskrun logs -f mytaskrun -n myspace
tkn condition --help
tkn condition delete mycondition1 -n myspace
tkn condition describe mycondition1 -n myspace
tkn condition list -n myspace
tkn resource -h
tkn resource create -n myspace
tkn resource delete myresource -n myspace
tkn resource describe myresource -n myspace
tkn resource list -n myspace
tkn clustertask --help
tkn clustertask delete mytask1 mytask2
tkn clustertask describe mytask1
tkn clustertask list
tkn clustertask start mytask
tkn eventlistener -h
tkn eventlistener delete mylistener1 mylistener2 -n myspace
tkn eventlistener describe mylistener -n myspace
tkn eventlistener list -n myspace
tkn eventlistener logs mylistener -n myspace
tkn triggerbinding -h
tkn triggerbinding delete mybinding1 mybinding2 -n myspace
tkn triggerbinding describe mybinding -n myspace
tkn triggerbinding list -n myspace
tkn triggertemplate -h
tkn triggertemplate delete mytemplate1 mytemplate2 -n `myspace`
tkn triggertemplate describe mytemplate -n `myspace`
tkn triggertemplate list -n myspace
tkn clustertriggerbinding -h
tkn clustertriggerbinding delete myclusterbinding1 myclusterbinding2
tkn clustertriggerbinding describe myclusterbinding
tkn clustertriggerbinding list
tkn hub -h
tkn hub --api-server https://api.hub.tekton.dev
tkn hub downgrade task mytask --to version -n mynamespace
tkn hub get [pipeline | task] myresource --from tekton --version version
tkn hub info task mytask --from tekton --version version
tkn hub install task mytask --from tekton --version version -n mynamespace
tkn hub reinstall task mytask --from tekton --version version -n mynamespace
tkn hub search --tags cli
tkn hub upgrade task mytask --to version -n mynamespace
tar xvf <file>
echo USDPATH
sudo mv ./opm /usr/local/bin/
C:\> path
C:\> move opm.exe <directory>
opm version
Version: version.Version{OpmVersion:"v1.15.4-2-g6183dbb3", GitCommit:"6183dbb3567397e759f25752011834f86f47a3ea", BuildDate:"2021-02-13T04:16:08Z", GoOs:"linux", GoArch:"amd64"}
tar xvf operator-sdk-v1.3.0-ocp-linux-x86_64.tar.gz
chmod +x operator-sdk
echo USDPATH
sudo mv ./operator-sdk /usr/local/bin/operator-sdk
operator-sdk version
operator-sdk version: "v1.3.0-ocp",
operator-sdk <command> [<subcommand>] [<argument>] [<flags>]
operator-sdk completion bash
bash completion for operator-sdk -*- shell-script -*- ex: ts=4 sw=4 et filetype=sh