EX280
EX280
EX280
##########################################################################
###on master do that
ssh-keygen -f .ssh/id_rsa -N ''
ssh-copy-id root@master
ssh-copy-id root@node
#on master
#docker-registry-cli workstation.lab.example.com:5000 search openshift3 ssl
#docker pull openshift/hello-openshift
docker-registry-cli workstation.lab.example.com:5000 search openshift ssl |
awk '$2~"Name" || $1~"Tag"{print $NF}'|xargs -n 2|sed 's/ /:/g' >
/root/images
cat /root/images|while read image ;do docker pull $image;done
scp /root/images root@node:/root/images
#on node
cat /root/images|while read image ;do docker pull $image;done
##########################################################################
##########################################################################
#on master and node
yum -y install wget git net-tools bind-utils iptables-services bridge-utils
atomic-openshift-docker-excluder atomic-openshift-excluder atomic-
openshift-utils
atomic-openshift-excluder unexclude
cp /etc/sysconfig/docker{,.back}
#on master
atomic-openshift-installer install
##########################################################################
##on master
#oc get pods
oc edit dc registry-console
#change line:image: registry.access.redhat.com/openshift3/registry-
console:3.3
image: workstation.lab.example.com:5000/openshift3/registry-console:3.3
oc edit is -n openshift
#chang all the registry.access.redhat.com =to=>
workstation.lab.example.com:5000
%s/registry.access.redhat.com/workstation.lab.example.com:5000/g
##########################################################################
##########################################################################
##on master
yum install httpd-tools
vim /etc/origin/master/master-config.yaml
#apiVersion:v1
kind: HTPasswdPasswordIdentityProvider
file: /etc/origin/openshift.passwd
##########################################################################
## on workstation
yum -y update
mkdir /{OSE_mysql,OSE_wordpress,OSE_registry}
chmod 777 /{OSE_mysql,OSE_wordpress,OSE_registry}
chown nfsnobody:nfsnobody /{OSE_mysql,OSE_wordpress,OSE_registry}
yum install nfs-utils rpcbind
cat >> /etc/exports << EOF
/OSE_mysql 172.25.250.0/24(rw,all_squash,async)
/OSE_wordpress 172.25.250.0/24(rw,all_squash,async)
/OSE_registry 172.25.250.0/24(rw,all_squash,async)
EOF
systemctl restart nfs-server ; systemctl enable nfs-server
## on master
oc project default
cat > OSE_registry-volume.json << EOF
{
"apiVersion": "v1",
"kind": "PersistentVolume", //资源类型为 PV
"metadata": {
"name": "exam-registry-volume", //PV 的名称,考题没有要求,但要注意避免与后
面的题目重复
"labels": {
"deploymentconfig": "docker-registry" //标签
}
},
"spec": {
"capacity": {
"storage": "2Gi" //容量,考题没有硬性要求,参考查看下 storage 主机的分区空
间
},
"accessModes": [ "ReadWriteMany" ], //访问权限,所有主机对该 PV 具有读写权限
"nfs": {
"path": "/OSE_registry", //NFS 共享目录
"server": "workstation.lab.example.com" //NFS 服务器域
}
}
}
EOF
##########################################################################
oc login https://master.lab.example.com:8443 -u randy -p boaterch
oc new-project shark --description="This is an EX280 project on OpenShift
v3"
oadm policy add-role-to-user view ryan -n shark
#oadm policy remove-role-from-user <role> <username>
oc login https://master.lab.example.com:8443 -u ryan -p boaterch
oc new-project farm --description="This is an EX280 project on OpenShift
v3"
oc new-project tokyo --description="This is an EX280 project on OpenShift
v3"
##########################################################################
##########################################################################
## on master , use git: http://workstation.lab.example.com/php-helloworld ;
use image : workstation.lab.example.com:5000/openshift3/php-55-rhel7
oc -o json new-app workstation.lab.example.com:5000/openshift3/php-55-
rhel7~http://workstation.lab.example.com/php-helloworld --name=gits2i >
git-s2i.json
oc create -f git-s2i.json
oc expose service gits2i --name=gits2iroute --
hostname=gits2i.cloudapps.lab.example.com --port=80
git clone http://workstation.lab.example.com/php-helloworld
cd php-helloworld
vim index.php
git add index.php
git commit -m "change"
git push
oc start-build gits2i
#or on web
Builds=>Builds=>php-helloworld=>Start Build
##########################################################################
##########################################################################
#on master import image:
wget http://rhgls.lab9.example.com/ex280/wordpress.tar #we should use
online docker to save a image like: docker save wordpress > wordpress.tar
docker load < wordpress.tar # docker load -i wordpress.tar
docker tag docker.io/wordpress
workstation.lab.example.com:5000/openshift3/wordpress
docker push workstation.lab.example.com:5000/openshift3/wordpress
#/root/wordprecc_prep.sh,is like:
#oc patch scc restricted -p '{"runAsUser":{"type":"RunAsAny"}}'
oc patch node master.lab.example.com node.lab.example.com -p '{"runAsUser":
{"type":"RanAsAny"}}'
#on master
:template,https://github.com/openshift/origin/blob/master/examples/
privileged-pod-pvc/
oc create -f mysql-volume.yaml
oc create -f mysql-pvclaim.yaml
oc create -f mysql-service.yaml
oc create -f wordpress-volume.yaml
oc create -f wordpress-pvclaim.yaml
oc create -f wordpress-pod.yaml
oc create -f mysql-service.yaml
oc create -f wordpress-service.yaml
#set route
#ay05.txt:#oc expose pod pod 名称 --name service 名称 --
selector='name=mysqldb'
#day05.txt:#oc expose service 路由名称 --port=8080
#day07.txt:#oc expose service instructor --hostname
instructor.cloudapps.lab.example.com
#oc expose service/<name> --name=routername --
hostname=wordpress.cloudapps.lab.example.com
oc expose service wpfrontend --name=wordpressroute --
hostname=wordpress.farm.cloudapps.lab.example.com --port=80
#then use the web domain visit and set
##########################################################################
##########################################################################
## on master #quota can use command do:oc create quota ex280-quota --
hard=memory=1Gi,cpu=2,replicationcontrollers=3,pods=12,services=6 ;and
then export quota as json,change for limits
oc login -u system:admin
oc project shark
##########################################################################
#on master
#oc export template XXX -o yaml > template.yaml
#or download template from
:https://github.com/openshift/origin/tree/release-3.7/examples/quickstarts,
like:https://raw.githubusercontent.com/openshift/rails-ex/master/
openshift/templates/rails-postgresql.json
oc project openshift #仅在 openshift 下创建的模版才可以给所有人使用
wget http://rhgls.lab9.example.com/materials/ex280-template.json
oc create -f ex280-template.json
# login web with the user randy who has the project shark
shark=>new project=>ex280-template=>
APPLICATION_NAME:ex280-app
APPLICATION_HOSTNAME:ex280-app.shark.devcloud.lab9.example.com
GIT_URI:http://git.lab9.example.com/git/ex280-app.git
=>create