docker run -itd --name okd -e "NODES=2" -p 9000:9000 -v /tmp/:/tmp/ -v /etc/docker/certs.d/:/certs/ -v /var/run/docker.sock:/var/run/docker.sock gustavonalle/oc-cluster-up
Monday, December 28, 2020
openshift 4.0
Friday, November 20, 2020
tar de docker centos7
https://github.com/luxknight007/centos7/blob/master/centos-7-docker.tar.xz
FROM scratch ADD centos-7-x86_64-docker.tar.xz / LABEL org.label-schema.schema-version="1.0" \ org.label-schema.name="CentOS Base Image" \ org.label-schema.vendor="CentOS" \ org.label-schema.license="GPLv2" \ org.label-schema.build-date="20191001" RUN yum -y update RUN yum -y install httpd CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"] EXPOSE 80
Thursday, November 19, 2020
casi armando un template
una demo de php,
https://github.com/mguazzardo/php-mysql-openshift
https://github.com/eformat/dbtest/blob/master/index.php
tremendo libro de openshift
https://assets.openshift.com/hubfs/pdfs/DevOps_with_OpenShift.pdf?hsLang=en-us
Wednesday, November 18, 2020
Creando builds desde la linea de comandos
Para crear un build config
oc new-build https://github.com/siamaksade/devnation-cicd-demo --name=mapit-build -n devnation
y para correrlo
oc start-build
para ver el bc
oc get bc/mapit-build -o yaml
recordemos que esto tira bastante basura....
Tuesday, November 17, 2020
mas sobre buildconfig
pipeline {
agent anytools {nodejs "node"}
stages {
stage('Cloning Git') {
steps {
git 'https://github.com/gustavoapolinario/node-todo-frontend'
}
}
stage('Install dependencies') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
}
Tremenda pagina de openshift pipelines
https://www.redpill-linpro.com/techblog/2018/11/09/openshift-jenkins-pipeline.html
sample pipeline
este es un ejemplo, breve para ver como generar un pipeline
kind:
"BuildConfig" apiVersion:
"v1" metadata: name: "sample-pipeline" spec: strategy: jenkinsPipelineStrategy: jenkinsfile: |- node('agent') { stage 'build' openshiftBuild(buildConfig:
'ruby-sample-build', showBuildLogs: 'true') stage 'deploy' openshiftDeploy(deploymentConfig:
'frontend') } |
Saturday, November 14, 2020
Script s2i
mkdir /tmp/s2i/ && cd /tmp/s2i/
curl -s https://api.github.com/repos/openshift/source-to-image/releases/latest \
| grep browser_download_url \
| grep linux-amd64 \
| cut -d '"' -f 4 \
| wget -qi -
tar xvf source-to-image*.gz
mv s2i /usr/local/bin
rm -rf /tmp/s2i/
Monday, November 2, 2020
NodeJeando, con swagger.
en esta oportunidad, nos toca ver como una simple app, con una API minimal, de una estructura mockeada, nos puede servir para alimentar swagger.
para esto, tenemos que tener los modulos
npm install express swagger swagger-ui swagger-ui-express body-parser
La página de donde saqué todo esto es
https://medium.com/bb-tutorials-and-thoughts/how-to-add-swagger-to-nodejs-rest-api-7a542cfdc5e1
y lo que sigue ahora es , la app, y la llamada a swagger.
comenté en un primer paso, el tema de los css.
const randomId = require('random-id'); const app = express(), bodyParser = require("body-parser"), fs = require('fs'), port = 3080; const swaggerUi = require('swagger-ui-express'); const swaggerDocument = require('./swagger.json'); //const customCss = fs.readFileSync((process.cwd() + "/swagger.css"), 'utf8'); // place holder for the data let tasks = [ { id: 1, task: 'task1', assignee: 'assignee1000', status: 'completed' }, { id: 2, task: 'task2', assignee: 'assignee1001', status: 'completed' }, { id: 3, task: 'task3', assignee: 'assignee1002', status: 'completed' }, { id: 4, task: 'task4', assignee: 'assignee1000', status: 'completed' }, ]; app.use(bodyParser.json()); app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, { customCss })); app.get('/api/todos', (req, res) => { console.log('api/todos called!!!!!') res.json(tasks); }); app.post('/api/todo', (req, res) => { const task = req.body.task; task.id = randomId(10); tasks.push(task); res.json(tasks); }) app.delete('/api/todo/:id', (req, res) => { console.log("Id to delete:::::", req.params.id) tasks = tasks.filter(task => task.id != req.params.id); res.json(tasks); }) app.put('/api/todos/:id', (req, res) => { console.log("Id to update:::::", req.params.id) const taskToUpdate = req.body.task; tasks = tasks.map(task => { if (task.id == req.params.id) { task = taskToUpdate; task.id = parseInt(req.params.id); } return task; }); res.json(tasks); }); app.get('/', (req, res) => { res.send(`<h1>API Running on port ${port}</h1>`); }); app.listen(port, () => { console.log(`Server listening on the port::::::${port}`); }); |
y la llamada a swagger.json
"swagger": "2.0", "info": { "description": "This is a simple example NodeJS API project to demonstrate Swagger Documentation", "version": "1.0.0", "title": "Tasks API", "contact": { "email": "abc@gmail.com" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "schemes": ["http"], "host": "localhost:3080", "basePath": "/api", "paths" : { "/todos" : { "get" : { "summary" : "Get all the tasks", "description": "Get all the tasks", "produces": ["application/json"], "parameters": [], "responses": { "200": { "description": "successful operation", "schema": { "type": "array", "items": { "$ref": "#/definitions/todosResponse" } } }, "400": { "description": "Invalid status value", "schema": { "$ref": "#/definitions/InvalidResponse" } } } } }, "/todo" : { "post" : { "summary" : "Save the task", "description": "Save the task", "produces": ["application/json"], "consumes": ["application/json"], "parameters": [ { "in": "body", "name": "body", "description": "task object", "required": true, "schema": { "type": "object", "properties": { "task": { "type": "object", "$ref": "#/definitions/Task" } } } } ], "responses": { "200": { "description": "successful operation", "schema": { "type": "array", "items": { "$ref": "#/definitions/todosResponse" } } }, "400": { "description": "Invalid status value", "schema": { "$ref": "#/definitions/InvalidResponse" } } } } }, "/todos/{id}" : { "put" : { "summary" : "Update the tasks", "description": "Update the tasks", "produces": ["application/json"], "parameters": [ { "name": "id", "in": "path", "description": "task id that needs to be deleted", "required": true, "type": "string" }, { "in": "body", "name": "body", "description": "task object", "required": true, "schema": { "type": "object", "properties": { "task": { "type": "object", "$ref": "#/definitions/Task" } } } } ], "responses": { "200": { "description": "successful operation", "schema": { "type": "array", "items": { "$ref": "#/definitions/todosResponse" } } }, "400": { "description": "Invalid status value", "schema": { "$ref": "#/definitions/InvalidResponse" } } } } }, "/todo/{id}" : { "delete" : { "summary" : "Delete the task", "description": "Delete the task", "produces": ["application/json"], "parameters": [ { "name": "id", "in": "path", "description": "task id that needs to be deleted", "required": true, "type": "string" } ], "responses": { "200": { "description": "successful operation", "schema": { "type": "array", "items": { "$ref": "#/definitions/todosResponse" } } }, "400": { "description": "Invalid status value", "schema": { "$ref": "#/definitions/InvalidResponse" } } } } } }, "definitions": { "todosResponse": { "type": "object", "properties": { "id": { "type": "integer" }, "task": { "type": "string" }, "assignee": { "type": "string" }, "status": { "type": "string" } } }, "Task": { "type": "object", "properties": { "task": { "type": "string" }, "assignee": { "type": "string" }, "status": { "type": "string" } } }, "InvalidResponse": { "type": "object", "properties": { "statusCode": { "type": "string" }, "message": { "type": "string" } } } } |