- Install virtual box on Mac OS
$ brew cask install virtualbox
- Install Minishift on Mac OS
$ brew cask install minishift
- Set VirtualBox as permanent vm-driver to start Minishift
$ minishift config set vm-driver virtualbox
$ minishift config view
- vm-driver : virtualbox
- Start Minishift installation
$ minishift start
or
$ minishift start --network-nameserver 8.8.8.8
# If you found error such as below, you may try other installation method:
err : exit status 1
output : Getting a Docker client ...
Checking if image openshift/origin-control-plane:v3.11.0 is available ...
Pulling image openshift/origin-cli:v3.11.0
E0329 04:49:59.885386 5326 helper.go:173] Reading docker config from /home/docker/.docker/config.json failed: open /home/docker/.docker/config.json: no such file or directory, will attempt to pull image docker.io/openshift/origin-cli:v3.11.0 anonymously
error: error pulling Docker image openshift/origin-cli:v3.11.0
# Debug:
$ minishift delete -f
$ minishift start --network-nameserver 8.8.8.8
- Check Minishift status
$ minishift status
Minishift: Running
Profile: minishift
OpenShift: Running (openshift v3.11.0+39132cb-398)
DiskUsage: 20% of 19G (Mounted On: /mnt/sda1)
CacheUsage: 1.678 GB (used by oc binary, ISO or cached images)
- (Optional) Enable admin (reference for addon)
$ minishift addon apply admin-user
$ minishift addon list
- admin-user : enabled P(0)
$ oc login -u admin
Authentication required for https://192.168.64.2:8443 (openshift)
Username: admin
Password: admin
Login successful.
- Open the Minishift on Webconsole
$ minishift console
# For the first time, "Your Connection is not Secure" will be displayed.
# Add the exception for your minishift console on the browser
# login with any user and any password (example: user developer, password anything)
$ minishift console --url
https://192.168.99.102:8443/console
# The shown URl should be your local minishift console URl
- Set oc command to the minishift path
$ eval $(minishift oc-env)
$ which oc
$ oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth
Server https://192.168.99.102:8443
kubernetes v1.11.0+d4cacc0
- Login to OpenShift
$ oc login -u developer -p anything
You have access to the following projects and can switch between them with 'oc project <projectname>':
* demo-project
myproject
# You may also specify the login URL:
$ oc login -u developer `minishift console --url`
- Enable the Registry Route for Minishift
$ minishift addon apply registry-route
-- Applying addon 'registry-route':
-- Create secret directory..
-- Creating server cert.
-- Creating the secret for the registry certificates.
-- Adding the secret to the registry pod’s service accounts (including the default service account)..
-- Pausing the docker-registry service.
-- Adding the secret volume to the registry deployment configuration.
-- Enabling TLS by adding the environment variables to the registry deployment configuration.
-- Updating the scheme used for the registry’s liveness probe from HTTP to HTTPS.
-- Updating the scheme used for the registry’s readiness probe from HTTP to HTTPS.
-- Resuming the docker-registry service.
-- Creating passthrough route for docker-registry service....
-- Add-on 'registry-route' created docker-registry route. Please run following commands to login to the OpenShift docker registry:
-- $ eval $(minishift docker-env)
-- $ eval $(minishift oc-env)
-- $ docker login -u developer -p `oc whoami -t` docker-registry-default.192.168.99.102.nip.io
- Login to Docker-Registry
$ docker login -u developer -p `oc whoami -t` docker-registry-default.192.168.99.102.nip.io
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
-Switch to different project
-Check the OpenShift Status
-Expose app to outside
oc expose svc/nodejs-ex --hostname=www.example.com
-Get Route
== OpenShift Cluster == -Start the OpenShift cluster
===== Project Management ===== -Show the current project context
-show all project current login has access to
-Show overview of current project resources
-Create a new project in Openshift and change to that context
-Create new project
-Get yaml configuration of a pod
-Adding a collaborator
collaborator = user (list by using oc whoami)
===== Image Stream =====
oc -o yaml new-app php~https://github.com/sandervanvugt/simpleapp --name=simple-app > simple-app.yaml
===== Deployment Config =====
===== Templates ===== -List templates
===== Persistent Storage (PV & PVC) ===== -Access modes for persistent storage: ReadWriteOnce (RWO) The volume can be mounted as read/write by a single node. ReadOnlyMany (ROX) The volume can be mounted as read-only by many nodes. ReadWriteMany (RWX) The volume can be mounted as read/write by many nodes.
�1】Setting up the NFS server:
�2】Create Persistent Volume (PV) -Create yaml(nfs-pv.yml) file: apiVersion: v1 kind: PersistentVolume metadata: name: nfs-pv spec: capacity: storage: 2Gi accessModes:
- ReadWriteMany persistentVolumeReclaimPolicy: Retain nfs: path: /storage server: 172.17.0.1 readOnly: false
�3】Adding Persistent Volume (PV)
�4】Creating Persistent Volume Claim (PVC) -Create yaml(nfs-pvc.yml) file: kind: PersistentVolumeClaim apiVersion: v1 metadata: name: nfs-pv-claim spec: accessModes:
- ReadWriteMany resources: requests: storage: 100Mi
�5】Creating PVC
�6】Creating the pod
(check the Volume section, also check Events)
-Create nfs-pv-pod.yaml kind: Pod apiVersion: v1 metadata: name: nfs-pv-pod spec: volumes: - name: nfsvolume (!this name is nothing todo with pv-name) persistentVolumeClaim: claimName: nfs-pv-claim containers: - name: nfs-client1 image: toccoag/openshift-nginx ports: - containerPort: 8081 name: "http-server1" volumeMounts: - mountPath: "/mnt" name: nfsvolume resources: {} - name: nfs-client2 image: toccoag/openshift-nginx ports: - containerPort: 8082 name: "http-server2" volumeMounts: - mountPath: "/nfsshare" name: nfsvolume resources: {}
�7】Verifying current configuration
- mount | grep mysql
===== ConfigMaps ===== ConfigMaps can be used to separate Dynamic Data from Static Data in a Pod ConfigMaps can be used in 3 different ways:
- make variables available within a Pod
- provide command line arguments
- mount them on the location where the application expects to find a configuration file
VAR_1=Hello VAR_2=World esc : wq!
-Create test-pod1.yml apiVersion: v1 kind: Pod metadata: name: example spec: containers: - name: example image: cirros command: ["/bin/sh", "-c", "env"] envFrom: - configMapRef: name: variables
===== OpenShift Troubleshoot ===== -Show recent events
-Show what has happened to specific pod
-Show pod details
-Show current working project
-Delete everything
===== Demo1 ===== oc login -u developer -p anything oc new-project firstproject oc new-app --docker-image=nginx:latest --name=nginx oc status (use it repeatedly to trace the process) oc get pods oc describe pod oc get svc oc describe service nginx oc port-forward 33080:80 curl -s http://localhost:33080
===== Demo2 ===== oc whoami oc new-project mysql oc new-app --docker-image=mysql:latest --name=mysql-openshift -e MYSQL_USER=myuser -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=mydb -e MYSQL_ROOT_PASSWORD=password oc status -v oc get all oc get pods -o=wide login to the Webconsoleand see the new application https://127.0.0.1:8443
��� OPENSHIFT ���
--ConfigMap
--Sample Yaml