From 2b529e2d8a32a13eb6703737d221960cc76a4c12 Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Date: Fri, 21 Sep 2018 01:48:10 -0400 Subject: [PATCH 1/6] fixing jenkins docker image tag --- lesson-jenkins/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson-jenkins/README.md b/lesson-jenkins/README.md index a17da0c..486893e 100644 --- a/lesson-jenkins/README.md +++ b/lesson-jenkins/README.md @@ -5,7 +5,7 @@ This directory includes a `Jenkinsfile` with specifications of the build pipelin ## To run Jenkins as a container ``` -docker run -it -v /var/run/docker.sock:/var/run/docker.sock -p8080:8080 getintodevops/jenkins-withdocker:lts +docker run -it -v /var/run/docker.sock:/var/run/docker.sock -p8080:8080 getintodevops/jenkins-withdocker:lts-docker18.06.0 ``` Access the Jenkins user interface in http://localhost:8080 From acddfe94e04036846451ff392a6a859ab56c355f Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Date: Fri, 21 Sep 2018 01:55:18 -0400 Subject: [PATCH 2/6] fixing rancher gcloud command --- lesson-rancher/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson-rancher/README.md b/lesson-rancher/README.md index c893c2d..1113374 100644 --- a/lesson-rancher/README.md +++ b/lesson-rancher/README.md @@ -3,7 +3,7 @@ In this lesson, we'll configure a virtual machine on Google Compute Engine to ru Run the following commands on Google Cloud Shell to create the Virtual Machine and firewall rule: ``` -gcloud beta compute instances create "rancher" --zone "us-east1-b" --machine-type "custom-1-8192-ext" --subnet "default" --maintenance-policy "MIGRATE" --no-service-account --no-scopes --min-cpu-platform "Automatic" --tags "rancher" --image "coreos-alpha-1576-1-0-v20171026" --image-project "coreos-cloud" --boot-disk-size "20" --boot-disk-type "pd-standard" --boot-disk-device-name "rancher" +gcloud beta compute instances create "rancher" --zone "us-east1-b" --machine-type "custom-1-8192-ext" --subnet "default" --maintenance-policy "MIGRATE" --no-service-account --no-scopes --min-cpu-platform "Automatic" --tags "rancher" --image "$(gcloud beta compute images list --filter="family:coreos-alpha" --format="value(NAME)")" --image-project "coreos-cloud" --boot-disk-size "20" --boot-disk-type "pd-standard" --boot-disk-device-name "rancher" ")" gcloud compute firewall-rules create rancher-test --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules="tcp:8000,tcp:8080,tcp:9000" --source-ranges=0.0.0.0/0 --target-tags=rancher ``` From 205b8ce5c06a4eb422041c33f168304a4f10200a Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Date: Fri, 21 Sep 2018 02:17:39 -0400 Subject: [PATCH 3/6] auto complete appended some character, so fixing that --- lesson-rancher/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson-rancher/README.md b/lesson-rancher/README.md index 1113374..01aebc1 100644 --- a/lesson-rancher/README.md +++ b/lesson-rancher/README.md @@ -3,7 +3,7 @@ In this lesson, we'll configure a virtual machine on Google Compute Engine to ru Run the following commands on Google Cloud Shell to create the Virtual Machine and firewall rule: ``` -gcloud beta compute instances create "rancher" --zone "us-east1-b" --machine-type "custom-1-8192-ext" --subnet "default" --maintenance-policy "MIGRATE" --no-service-account --no-scopes --min-cpu-platform "Automatic" --tags "rancher" --image "$(gcloud beta compute images list --filter="family:coreos-alpha" --format="value(NAME)")" --image-project "coreos-cloud" --boot-disk-size "20" --boot-disk-type "pd-standard" --boot-disk-device-name "rancher" ")" +gcloud beta compute instances create "rancher" --zone "us-east1-b" --machine-type "custom-1-8192-ext" --subnet "default" --maintenance-policy "MIGRATE" --no-service-account --no-scopes --min-cpu-platform "Automatic" --tags "rancher" --image "$(gcloud beta compute images list --filter="family:coreos-alpha" --format="value(NAME)")" --image-project "coreos-cloud" --boot-disk-size "20" --boot-disk-type "pd-standard" --boot-disk-device-name "rancher" gcloud compute firewall-rules create rancher-test --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules="tcp:8000,tcp:8080,tcp:9000" --source-ranges=0.0.0.0/0 --target-tags=rancher ``` From 5e9c467dcfeb2f56856a19baad0055fb78a7de3b Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Date: Fri, 21 Sep 2018 02:57:44 -0400 Subject: [PATCH 4/6] moving around so jenkins works --- .../hello-node-app => hello-node-app}/main.js | 0 .../package.json | 0 .../hello-node-app => hello-node-app}/test.js | 0 lesson-jenkins/Dockerfile | 22 ----------- lesson-jenkins/Jenkinsfile | 37 ------------------- lesson-jenkins/README.md | 13 ------- 6 files changed, 72 deletions(-) rename {lesson-jenkins/hello-node-app => hello-node-app}/main.js (100%) rename {lesson-jenkins/hello-node-app => hello-node-app}/package.json (100%) rename {lesson-jenkins/hello-node-app => hello-node-app}/test.js (100%) delete mode 100644 lesson-jenkins/Dockerfile delete mode 100644 lesson-jenkins/Jenkinsfile delete mode 100644 lesson-jenkins/README.md diff --git a/lesson-jenkins/hello-node-app/main.js b/hello-node-app/main.js similarity index 100% rename from lesson-jenkins/hello-node-app/main.js rename to hello-node-app/main.js diff --git a/lesson-jenkins/hello-node-app/package.json b/hello-node-app/package.json similarity index 100% rename from lesson-jenkins/hello-node-app/package.json rename to hello-node-app/package.json diff --git a/lesson-jenkins/hello-node-app/test.js b/hello-node-app/test.js similarity index 100% rename from lesson-jenkins/hello-node-app/test.js rename to hello-node-app/test.js diff --git a/lesson-jenkins/Dockerfile b/lesson-jenkins/Dockerfile deleted file mode 100644 index 24f5423..0000000 --- a/lesson-jenkins/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# use a node base image -FROM node:8 - -# set maintainer -LABEL maintainer "miiro@getintodevops.com" - -# run a command inside the container -# this will create a directory for our application -RUN mkdir -p /app - -# set the working directory to our app directory -WORKDIR /app - -# copy our application inside the container -COPY hello-node-app/* /app/ - -# tell docker what port to expose -EXPOSE 8000 - -# tell docker what command to run when container is run -CMD npm start - diff --git a/lesson-jenkins/Jenkinsfile b/lesson-jenkins/Jenkinsfile deleted file mode 100644 index c5f5810..0000000 --- a/lesson-jenkins/Jenkinsfile +++ /dev/null @@ -1,37 +0,0 @@ -node { - def app - - stage('Clone repository') { - /* Let's make sure we have the repository cloned to our workspace */ - - checkout scm - } - - stage('Build image') { - /* This builds the actual image; synonymous to - * docker build on the command line */ - - app = docker.build("getintodevops/hellonode") - } - - stage('Test image') { - /* Ideally, we would run a test framework against our image. - * This runs only a single dummy test inside the image. */ - - app.inside { - sh 'npm test' - } - } - - stage('Push image') { - /* Finally, we'll push the image with two tags: - * First, the incremental build number from Jenkins - * Second, the 'latest' tag. - * Pushing multiple tags is cheap, as all the layers are reused. */ - docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { - app.push("${env.BUILD_NUMBER}") - app.push("latest") - } - } -} - diff --git a/lesson-jenkins/README.md b/lesson-jenkins/README.md deleted file mode 100644 index 486893e..0000000 --- a/lesson-jenkins/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Lesson: Jenkins -In this lesson, we will be configuring a Continuous Integration pipeline in Jenkins to build a Hello Node Docker image whenever there's a commit to the code repository. - -This directory includes a `Jenkinsfile` with specifications of the build pipeline, a `Dockerfile` for building the Docker image, and the application itself. - -## To run Jenkins as a container -``` -docker run -it -v /var/run/docker.sock:/var/run/docker.sock -p8080:8080 getintodevops/jenkins-withdocker:lts-docker18.06.0 -``` - -Access the Jenkins user interface in http://localhost:8080 - -https://getintodevops.com From a3c981918a463caf0af568d9d6ac283cd5c4326e Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Date: Fri, 21 Sep 2018 02:58:24 -0400 Subject: [PATCH 5/6] keeping everything updated --- .gitmodules | 3 +++ hello-node-app/main.js | 13 ------------- hello-node-app/package.json | 23 ----------------------- hello-node-app/test.js | 7 ------- lesson-jenkins | 1 + 5 files changed, 4 insertions(+), 43 deletions(-) create mode 100644 .gitmodules delete mode 100644 hello-node-app/main.js delete mode 100644 hello-node-app/package.json delete mode 100644 hello-node-app/test.js create mode 160000 lesson-jenkins diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..444f971 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lesson-jenkins"] + path = lesson-jenkins + url = git@github.com:elreydetoda/hellonode.git diff --git a/hello-node-app/main.js b/hello-node-app/main.js deleted file mode 100644 index 8cc2d52..0000000 --- a/hello-node-app/main.js +++ /dev/null @@ -1,13 +0,0 @@ -// load the http module -var http = require('http'); - -// configure our HTTP server -var server = http.createServer(function (request, response) { - response.writeHead(200, {"Content-Type": "text/plain"}); - response.end("Hello getintodevops.com\n"); -}); - -// listen on localhost:8000 -server.listen(8000); -console.log("Server listening at http://127.0.0.1:8000/"); - diff --git a/hello-node-app/package.json b/hello-node-app/package.json deleted file mode 100644 index 58a4f9c..0000000 --- a/hello-node-app/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "getintodevops-hellonode", - "version": "1.0.0", - "description": "A Hello World HTTP server", - "main": "main.js", - "scripts": { - "test": "node test.js", - "start": "node main.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/getintodevops/masterclass-codeexamples/" - }, - "keywords": [ - "node", - "docker", - "dockerfile" - ], - "author": "miiro@getintodevops.com", - "license": "ISC", - "devDependencies": { "test": ">=0.6.0" } -} - diff --git a/hello-node-app/test.js b/hello-node-app/test.js deleted file mode 100644 index 71772b3..0000000 --- a/hello-node-app/test.js +++ /dev/null @@ -1,7 +0,0 @@ -var assert = require('assert') - -function test() { - assert.equal(2 + 2, 4); -} - -if (module == require.main) require('test').run(test); \ No newline at end of file diff --git a/lesson-jenkins b/lesson-jenkins new file mode 160000 index 0000000..2241f48 --- /dev/null +++ b/lesson-jenkins @@ -0,0 +1 @@ +Subproject commit 2241f48e193a956e9c25706555ee3e4c9c0728c5 From ffe0c71fb5d266aee02a2e7d7adf571f99d42b85 Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Date: Sat, 22 Sep 2018 23:00:32 -0400 Subject: [PATCH 6/6] updating with my stuff --- lesson-jenkins | 2 +- lesson-openstack/README.md.02 | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 lesson-openstack/README.md.02 diff --git a/lesson-jenkins b/lesson-jenkins index 2241f48..e37d8fa 160000 --- a/lesson-jenkins +++ b/lesson-jenkins @@ -1 +1 @@ -Subproject commit 2241f48e193a956e9c25706555ee3e4c9c0728c5 +Subproject commit e37d8fae6121413a39908235429f2c2f317abb0f diff --git a/lesson-openstack/README.md.02 b/lesson-openstack/README.md.02 new file mode 100644 index 0000000..1b7a1f4 --- /dev/null +++ b/lesson-openstack/README.md.02 @@ -0,0 +1,48 @@ +# Lesson: Openstack + +In this lesson, we'll be using Openstack with DevStack. DevStack is a tool that runs a complete Openstack environment on a single server. Because installing DevStack requires various changes to network configuration of the server it's installed on, we'll be creating a new virtual machine for it in Google Cloud Platform. + +Using the skills you have learned in the previous lessons, provision a new virtual machine on Google Compute Engine. Create a server with 2 VCPUs, 8 gigabytes of memory and 100GB root disk with the Ubuntu 16.04 operating system. Also, create a firewall rule to allow TCP port 80 inbound from any source. + +Finally, SSH into the new virtual machine (either via Google Cloud Shell or externally) and follow the instructions below to install DevStack. Note that the installation will take about 15 minutes. + +## Install DevStack + +First, create a user for running DevStack: +``` +sudo useradd -s /bin/bash -d /opt/stack -m stack +``` + +Enable this user to sudo without a password: +``` +echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack +``` + +Open a shell as the stack user: +``` +sudo su - stack +``` + +Download DevStack via git: +``` +git clone https://git.openstack.org/openstack-dev/devstack +cd devstack +``` + +Create the minimum configuration for installing DevStack: +``` +echo -e "[[local|localrc]]\nADMIN_PASSWORD=masterclass\nDATABASE_PASSWORD=\$ADMIN_PASSWORD\nRABBIT_PASSWORD=\$ADMIN_PASSWORD\nSERVICE_PASSWORD=\$ADMIN_PASSWORD" > local.conf +``` + +Alter the packages needed to install because mysql is out of date +``` +for i in $(sudo grep -r 'libmysqlclient-dev' * | cut -d ':' -f 1) ; do sed -i 's/libmysqlclient-dev/default-libmysqlclient-dev/' $i ; done +``` + +Start the DevStack installation: +``` +./stack.sh +``` + +When the installation is complete, login to the Openstack dashboard in `http:///dashboard/` using the username `demo` and password `masterclass`. +