Вы находитесь на странице: 1из 27

Url

https://console.apps.f6115a399213483d96ac.eastus.azmosa.io

Usuario: manuel.gutierrezgro@imss.gob.mx

Password: M@nu*2019
https://github.com/openshift/origin/releases/tag/v3.11.0

C:\MAGG\Software\OC Tools v3.11

Descomprimir en local
Conectarme por consola
Crear proyectos

oc new-project dev2 --display-name="Task – Dev2"


oc new-project stage2 --display-name="Tasks – Stage2"
oc new-project cicdpoc --display-name="CICD POC"
Conceder permisos a Jenkins accesos a los proyectos
oc policy add-role-to-group edit system:serviceaccounts:cicdpod -n dev2
oc policy add-role-to-group edit system:serviceaccounts:cicdpod -n stage2

oc policy add-role-to-group edit system:serviceaccounts:default:jenkins -n dev2


oc policy add-role-to-group edit system:serviceaccounts:default:jenkins -n stage2

oc policy add-role-to-user edit system:serviceaccount:default:jenkins -n dev2

oc policy add-role-to-user edit system:serviceaccount:default:jenkins -n stage2

C:\OCv311>oc policy add-role-to-group edit system:serviceaccounts:cicdpod


-n dev2
role "edit" added: "system:serviceaccounts:cicdpod"

C:\OCv311>oc policy add-role-to-group edit system:serviceaccounts:cicdpod


-n stage2
role "edit" added: "system:serviceaccounts:cicdpod"
Veo los proyectos creados

C:\OCv311>oc get projects


NAME DISPLAY NAME STATUS
cicdpoc CICD POC Active
dev2 Task – Dev2 Active
stage2 Tasks – Stage2 Active
oc process -n cicdpoc -f https://raw.githubusercontent.com/nichochen/openshift-cd-demo/azure-redhat-
openshift-3.11/cicd-template.yaml --param DEV_PROJECT=dev2 --param STAGE_PROJECT=stage2 | oc create -f
-

Salida

C:\OCv311>oc process -n cicdpoc -f


https://raw.githubusercontent.com/nichochen/openshift-cd-demo/azure-redhat-
openshift-3.11/cicd-template.yaml --param DEV_PROJECT=dev2 --param
STAGE_PROJE
CT=stage2 | oc create -f -
rolebinding.authorization.openshift.io/default_admin created
buildconfig.build.openshift.io/tasks-pipeline created
configmap/jenkins-slaves created
job.batch/cicd-demo-installer created

Exportar los recursos como Templates

Me posiciono en el proyecto que deseo hacer el template

C:\Users\Bug\.minishift\cache\oc\v3.9.14\windows>oc project dev


Now using project "dev" on server "https://console.cloud.igalvan.com:443"
https://docs.openshift.com/container-platform/3.9/dev_guide/templates.html

https://docs.openshift.com/container-platform/3.5/dev_guide/templates.html#creating-from-templates-using-
the-web-console

https://blog.openshift.com/part-2-creating-a-template-a-technical-walkthrough/

C:\Users\Bug\.minishift\cache\oc\v3.9.14\windows>oc export all --as-


template=devgoogle > t_devgoogle

oc export all -o json --as-template=devgoogle > t_devgoogle.json

oc export all -o json –-selector=”application=tasks” --as-


template=stagetasksgoogle > t_stagetasksgoogle.json

oc export all -o json -l name=tasks --as-template=devtasksgoogle >


t_devtasksgoogle.json

oc get all

oc export all -o json --selector="app=tasks" --as-template=devtasksgoogle >


t_devtasksgoogle.json
oc export all -o json --selector="app=tasks" --as-template=stagetasksgoogle
> t_stagetasksgoogle.json

oc export all -o json --selector="app= cicd-demo-installer" --as-


template=devinstallgoogle > t_devinstallgoogle.json
oc export all -o json --selector="app= wildfly" --as-
template=devwildflygoogle > t_devwildflygoogle.json

Muy buen post

https://blog.openshift.com/part-2-creating-a-template-a-technical-walkthrough/

----------------
$ oc login <source_environment>
$ oc project <source_project>
$ oc export dc,is,svc,route,secret,sa -l promotion-group=<application_name> -o yaml
> export.yaml
$ oc login <target_environment>
$ oc new-project <target_project>
$ oc create -f export.yaml

---------------

Ejemplo
oc export dc,svc,bc --selector="microservice=imagesvc" -o yaml --as-template=imagesvc

why labels are important


Labels can be used for filtering resources on a query, for example:
$ oc get buildconfig --selector="application=mlbparks"
$ oc get deploymentconfig --selector="deploymentConfig=mlbparks"

Also, they can be used to delete in one operation every resource we have created, like:
$ oc delete all --selector="application=mlbparks"

Registrar template
Registering the template for use in a Project
We will execute the creation of the template as a user in the current project. (The user will
need to have the appropriate roles to create “Template” resources in the current project)
$ oc create -f my_template.json

If the user belongs to multiple projects, and wants to create the template in a different
project from the one he’s currently working on, he can do it with -n <project>.
$ oc create -f my_template.json -n <project>

oc create -f t_devwildflygoogle.json -n dev2

oc create -f t_devtasksgoogle.json -n dev2

oc create -f t_stagetasksgoogle.json -n stage2

Ahora vamos a la consola y creamos los proyectos desde templates


Ambientar stage 2
Correr el pipeline
oc adm policy add-cluster-role-to-user
processedtemplates.template.openshift.io system:serviceaccount:baft:jenkins
-n baft-test

oc manuel.gutierrezgro@metro.imss.gob.mx policy add-cluster-role-to-user


buildconfigs.build.openshift.io system:serviceaccount:default:jenkins -n dev2
manuel.gutierrezgro@metro.imss.gob.mx

oc policy add-role-to-user buildconfigs.build.openshift.io system:serviceaccount:default:jenkins


-n dev2

oc policy add-role-to-user edit system:serviceaccount:default:jenkins -n stage2

Elimino el template “devtasksgoogle”

C:\OCv311>oc get templates -n dev2


NAME DESCRIPTION PARAMETERS OBJECTS
devwildflygoogle 0 (all set) 5

C:\OCv311>oc delete template/devtasksgoogle -n dev2


template.template.openshift.io "devtasksgoogle" deleted
Elimino el recurso de task

oc project dev2
C:\OCv311>oc delete all --selector=”app=tasks”

Como comete error, voy a eliminarlo desde consola


Reviso que se haya eliminado todo

Registro de nuevo el template

oc project dev2

oc create -f t_devtasksgoogle.json -n dev2


Creo de nuevo el tasks
https://blog.openshift.com/part-2-creating-a-template-a-technical-walkthrough/

https://docs.openshift.com/container-platform/3.5/dev_guide/templates.html#creating-from-templates-using-
the-web-console

https://dev.to/wangonya/creating-a-simple-todo-api-with-django-2i1c

https://stackoverflow.com/questions/44702369/openshift-create-template-from-existing-setup

https://developers.redhat.com/blog/2019/09/11/develop-with-django-2-and-python-3-in-a-container-with-
red-hat-enterprise-linux/

https://docs.djangoproject.com/es/2.2/intro/tutorial01/

https://www.jetbrains.com/help/pycharm/running-manage-py.html

https://www.jetbrains.com/help/pycharm/templates.html

https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html

http://127.0.0.1:8000/pyapppoc/

https://docs.djangoproject.com/es/2.2/intro/tutorial03/

https://blog.openshift.com/part-2-creating-a-template-a-technical-walkthrough/

http://aroworkshop.io/

https://github.com/OpenShiftDemos/openshift-tasks

https://github.com/nichochen/openshift-cd-demo

https://github.com/siamaksade/openshift-cd-demo/blob/ocp-4.1/cicd-template.yaml

Вам также может понравиться