Skip to content

Instantly share code, notes, and snippets.

@rmarins
Last active May 23, 2020 20:13
Show Gist options
  • Save rmarins/e1993c0ff8511681043f17c9126b2e49 to your computer and use it in GitHub Desktop.
Save rmarins/e1993c0ff8511681043f17c9126b2e49 to your computer and use it in GitHub Desktop.

Creating Kubernetes Resources

Usage of oc command

$ oc <command>

Logging in to a Cluster

$ oc login <clusterUrl>
oc new-app --docker-image=registry.access.redhat.com/rhscl/mysql-57-rhel7:lastest \
    --name=mysql-openshift -e MYSQL_USER=user1 -e MYSQL_PASSWORD=mypa55 \
    -e MYSQL_DATABASE=testdb -e MYSQL_ROOT_PASSWORD=r00tpa55

Creating Routes

$ oc expose service quotedb --name quote

Leveraging the Default Routing Service

$ oc get pod --all-namespaces -l app=router

NAMESPACE           NAME                        READY   STATUS      RESTARTS    AGE
openshift-ingress   router-default-746b5cfb65   1/1     Running     1           4d

Use oc describe pod command to get the routing configuration details:

$ oc get pod router-default-746b5cfb65

Name:           router--default-746b5cfb65-f6sdm
Namespace:      openshift-ingress
...output omitted...
Containers:
  router:
...output omitted...
    Environment:
      STATS_PORT:                   1936
      ROUTER_SERVICE_NAMESPACE:     openshift-ingress
      DEFAULT_CERTIFICATE_DIR:      /etc/pki/tls/private
      ROUTER_SERVICE_NAME:          default
      ROUTER_CANONICAL_HOSTNAME:    apps.cluster.lab.example.com
...output omitted...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment