OpenShift: Difference between revisions
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Install= | =Install= | ||
==Install Docker== | |||
You will need to google the way to get the repository | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
apt- | sudo apt update && sudo apt -y install docker-ce | ||
systemctl start docker | systemctl start docker | ||
systemctl enable docker | systemctl enable docker | ||
systemctl status docker | systemctl status docker | ||
</syntaxhighlight> | |||
==Set your user to user docker group== | |||
<syntaxhighlight lang="bash"> | |||
sudo usermod -aG docker $USER | |||
</syntaxhighlight> | |||
==Allow insecure Registry== | |||
<syntaxhighlight lang="bash"> | |||
sudo cat << EOF | sudo tee /etc/docker/daemon.json | |||
{ | |||
"insecure-registries" : [ "172.30.0.0/16" ] | |||
} | |||
EOF | |||
</syntaxhighlight> | |||
==Restart Docker== | |||
<syntaxhighlight lang="bash"> | |||
systemctl restart docker | |||
</syntaxhighlight> | |||
==Get OpenShift and copy binaries== | |||
Get the package | |||
<syntaxhighlight lang="bash"> | |||
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz | 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 | 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 | cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit | ||
sudo mv oc kubectl /usr/local/bin/ | sudo mv oc kubectl /usr/local/bin/ | ||
</syntaxhighlight> | |||
==Make Directory== | |||
The directories are too long so we need to run the code from /opt/openshift | |||
<syntaxhighlight lang="bash"> | |||
cp -r * /opt/openshift | |||
cd /opt/openshift | |||
oc cluster up --public-hostname=your-server-ip | |||
</syntaxhighlight> | |||
==Fix DNS== | |||
'''IMPORTANT''' | |||
Edit the file: openshift.local.clusterup/node/node-config.yml and set dnsIP | |||
<syntaxhighlight lang="bash"> | |||
dnsIP: "8.8.8.8" | |||
</syntaxhighlight> | |||
Edit the file openshift.local.clusterup/kubedns/resolv.conf and add | |||
<syntaxhighlight lang="bash"> | |||
nameserver 8.8.8.8 | |||
nameserver 8.8.4.4 | |||
</syntaxhighlight> | |||
Also make sure you have the DNS options inside the docker config file | |||
<br> | |||
Edit /etc/docker/daemon.json and add this but do not forget the comma if it already has something | |||
<syntaxhighlight lang="bash"> | |||
"dns": ["8.8.8.8", "8.8.4.4"] | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 21: | Line 62: | ||
sudo oc cluster up | sudo oc cluster up | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Create And Build a Project= | |||
==Example 1== | |||
<syntaxhighlight lang="bash"> | |||
// 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 | |||
</syntaxhighlight> | |||
=Pods= | =Pods= | ||
OpenShift Pods contain containers. It is recommended one pod per container. | OpenShift Pods contain containers. It is recommended one pod per container. | ||
Line 38: | Line 92: | ||
**Support for several programming language | **Support for several programming language | ||
**Customizable | **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 |
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