Giter Site home page Giter Site logo

crc-openshift's Introduction

crc-openshift

CRC

So you've installed Code Ready Containers (= OpenShift for developers) and you've created a project named "myproject" to play around ...

$ crc setup
$ crc start 
$ oc login -u kubeadmin -p <SOME_PASSWORD> https://api.crc.testing:6443
$ oc new-project myproject

quay.io

Then you need some container registry to save the images you build ... then:

  • create an account on quay.io *
  • create an "Organization" named "my-quay-org"
  • create a public repository named "my-quay-repo"
  • create a "Robot Account" named "myquayrobot"
  • grant "write" permissions to "myquayrobot" on "my-quay-repo"
  • login to your repo using podman using the "Docker Login" credentials of "myquayrobot" (on my Fedora):
    $ sudo podman login -u="my-quay-org+myquayrobot" -p="AFL44C0L1AOXF5C70FK363F17NH4MRPTW7OYRVIA15LDXWWY66SYPIBO3QCL8ORO" quay.io
    
  • use the "Kubernetes Secret" of "myquayrobot" to create a secret in CRC
    $ oc create -f ~/Downloads/my-quay-org-myquayrobot-secret.yml --namespace=myproject
    

Create Image

Now use the Dockerfile to create an image and upload it to quay.io:

$ sudo podman build . -t quay.io/my-quay-org/my-quay-repo
$ sudo podman push quay.io/my-quay-org/my-quay-repo

Run the image in CRC

$ oc secrets link default my-quay-org-myquayrobot-pull-secret --for pull
$ oc new-app --docker-image=quay.io/my-quay-org/my-quay-repo
$ oc get pods
$ oc logs my-quay-repo-1-hkdlb

Note the name "my-quay-repo-1-hkdlb" was derived from the "oc get pods" output

Config Maps and Secrets

We add some secrets as files into the DeploymentConfig:

$ echo "value1" > /tmp/key1.txt
$ echo "value2" > /tmp/key2.txt
$ echo "value3" > /tmp/key3.txt
$ oc create secret generic sec-files --from-file /tmp/key1.txt --from-file /tmp/key2.txt --from-file /tmp/key3.txt
$ oc set volume dc/my-quay-repo --add -t secret -m /opt/app-root/sec-files --name myappsec-files --secret-name sec-files
$ oc rsh my-quay-repo-5-z9pl2
sh-4.4$ ls -l /opt/app-root/sec-files
total 0
lrwxrwxrwx. 1 root root 15 Dec  8 08:57 key1.txt -> ..data/key1.txt
lrwxrwxrwx. 1 root root 15 Dec  8 08:57 key2.txt -> ..data/key2.txt
lrwxrwxrwx. 1 root root 15 Dec  8 08:57 key3.txt -> ..data/key3.txt
sh-4.4$ cat /opt/app-root/sec-files/*
value1
value2
value3

We do the same with a config map, but this time we add it to DeploymentConfig as env variables:

$ oc create configmap test-config-map --from-literal CHIAVE1=VALORE1 --from-literal CHIAVE2=VALORE2
$ oc patch configmap/test-config-map --patch '{"data":{"CHIAVE2":"NUOVOVALORE2"}}'
$ oc get configmap/test-config-map -o json
$ oc set env dc/my-quay-repo --from configmap/test-config-map
$ oc rsh my-quay-repo-6-p6k7n
sh-4.4$ echo $CHIAVE2
NUOVOVALORE2
sh-4.4$ env
_=/usr/bin/env
HOSTNAME=my-quay-repo-6-p6k7n
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_ADDR=172.25.0.1
container=oci
KUBERNETES_PORT=tcp://172.25.0.1:443
PWD=/
HOME=/
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP=tcp://172.25.0.1:443
CHIAVE1=VALORE1
CHIAVE2=NUOVOVALORE2
TERM=xterm-256color
NSS_SDB_USE_CACHE=no
SHLVL=2
KUBERNETES_SERVICE_PORT=443
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_SERVICE_HOST=172.25.0.1

crc-openshift's People

Contributors

tommy74 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.