Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Last active October 8, 2019 20:50
Show Gist options
  • Save arttuladhar/23ac69ac6706d7ee2e0597f8dec3211b to your computer and use it in GitHub Desktop.
Save arttuladhar/23ac69ac6706d7ee2e0597f8dec3211b to your computer and use it in GitHub Desktop.

Starting Minishift with VirtualBox

# Starting Minishift
minishift start

# Starting Minishift using VirtrualBox
minishift start --vm-driver virtualbox

## Get Minishift Status
minishift status
# Show recent events
oc get events

# Log on specific pod
oc logs <podname>

# Details about Pod
oc describe pod <podname>

# Show Projects
oc projects

# Delete all with Label
oc delete all -l app=simpleapp

Login

oc login -u developer -p whatever

Project

oc new-project <projectname> \
    --description=<description> \
    --display-name=<display_name>

New App

# New App from Docker Image
oc new-app --docker-image=nginx:1.14 --name=nginx

# New App from GitHub (S2I)
oc new-app https://github.com/arttuladhar/hello-node.git -l name=hello-nodejs

# Generate YAML for New App
oc -o yaml new-app php~http://gitserver/local/app --name=myapp > s2i.yaml

Builds

oc start-build <build-name> —follow

# Add trigger to a build, on completion of another build
oc set trigger bc/my-build-after —from-image=my-build:latest

Image Stream

# Crete Image Stream
oc create is image-stream-name

# Get Image Stream
oc get is -n openshift
oc get is Jenkins -o yaml

# Describe Image Stream
oc describe is jenkins -n openshift

# Import Image from an external Registry
oc import-image —from=<registry_url>

Deployment Configs and Networking

oc get dc
oc get rc
oc describe rc <rc-name>

Pods

# Get All Pods
oc get pods
oc get pods --show-labels

# Get Pod
oc get pod <podname>

# Describe Pod using Label Selector
oc describe pod -l app=hello-node

# Port Forward Pod
oc port-forward nginx-1-7vkck 4040:8080

Routes and Services

oc get svc -n default
oc expose service hello-nodejs
oc get route
# Delete All Resources using Label Selector
oc delete all -l app=jenkins-ephemeral

User Roles

# Grant permissions for a build to pull an image from another project
oc policy add-role-to-user system:image-puller system:serviceaccount:yourbuildproject:builder -n namespace

Secrets

oc secrets new-basicauth gitsecret —username=jsmith —password=secret
oc secrets link sa/builder secret/gitsecret

Templates

# Get Template
oc get templates -n openshift

# Create Template from Filename
oc create -f <filename>

# Create objects from a template by processing the template and piping the output to oc create
oc process -f nist-data-mirror-deployment-config.yml | oc create -f -

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment