OpenShift: Difference between revisions
Line 63: | Line 63: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Create And Build a Project= | =Create And Build a Project= | ||
==Example 1== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
// Create project | // Create project | ||
Line 72: | Line 73: | ||
// Resubmit Build | // Resubmit Build | ||
oc start-build ruby-ex | oc start-build ruby-ex | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 07:07, 24 December 2020
Install
Install Docker
You will need to google the way to get the repository
sudo apt update && sudo apt -y install docker-ce
systemctl start docker
systemctl enable docker
systemctl status docker
Set your user to user docker group
sudo usermod -aG docker $USER
Allow insecure Registry
sudo cat << EOF | sudo tee /etc/docker/daemon.json
{
"insecure-registries" : [ "172.30.0.0/16" ]
}
EOF
Restart Docker
systemctl restart docker
Get OpenShift and copy binaries
Get the package
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
tar -xvzf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
sudo mv oc kubectl /usr/local/bin/
Make Directory
The directories are too long so we need to run the code from /opt/openshift
cp -r * /opt/openshift
cd /opt/openshift
oc cluster up --public-hostname=your-server-ip
Fix DNS
IMPORTANT Edit the file: openshift.local.clusterup/node/node-config.yml and set dnsIP
dnsIP: "8.8.8.8"
Edit the file openshift.local.clusterup/kubedns/resolv.conf and add
nameserver 8.8.8.8
nameserver 8.8.4.4
Also make sure you have the DNS options inside the docker config file
Edit /etc/docker/daemon.json and add this but do not forget the comma if it already has something
"dns": ["8.8.8.8", "8.8.4.4"]
Start Stop Cluster
sudo oc cluster down
sudo oc cluster up
Create And Build a Project
Example 1
// Create project
oc new-project test01 --display-name="Test 01 Project" --description="My 01 Test Project Description"
// Add app
oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git
// Look at the logs
oc logs -f bc/ruby-ex
// Resubmit Build
oc start-build ruby-ex
Pods
OpenShift Pods contain containers. It is recommended one pod per container.
Deployment
There are 3 ways to deploy an openshift container.
- Predefined containers
- Manual
- Dockerfile
- Yaml
- Most flexible
- Openshift Application catalogue
- Predefined application
- Easy to deploy
- Easy to integrate into custom applications
- Source to Image (s2i)
- Fastest to deploy
- Support for several programming language
- Customizable
List of 3.1 commands
- Basic CLI Operations
- types
- login
- logout
- new-project
- new-app
- status
- project
- Application Modification CLI Operations
- get
- describe
- edit
- env
- volume
- label
- expose
- delete
- Build and Deployment CLI Operations
- start-build
- deploy
- rollback
- new-build
- cancel-build
- import-image
- scale
- tag
- Advanced Commands
- create
- update
- process
- run
- export
- policy
- secrets
- Troubleshooting and Debugging CLI Operations
- logs
- exec
- rsh
- rsync
- port-forward
- proxy
oc commands
- sudo oc login
Login so you can do stuff
- sudo oc config view
View configured clusters
- oc project
View current project
- oc status
Show status
- oc get projects
Show all projects
- oc delete project <project_name>
Deleting a project
- oc get pods
Shows the status of the pods
- oc describe pod iainapp01-1-build
Shows status of an individual pod