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/lesson-jenkins b/lesson-jenkins new file mode 160000 index 0000000..e37d8fa --- /dev/null +++ b/lesson-jenkins @@ -0,0 +1 @@ +Subproject commit e37d8fae6121413a39908235429f2c2f317abb0f 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 a17da0c..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 -``` - -Access the Jenkins user interface in http://localhost:8080 - -https://getintodevops.com diff --git a/lesson-jenkins/hello-node-app/main.js b/lesson-jenkins/hello-node-app/main.js deleted file mode 100644 index 8cc2d52..0000000 --- a/lesson-jenkins/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/lesson-jenkins/hello-node-app/package.json b/lesson-jenkins/hello-node-app/package.json deleted file mode 100644 index 58a4f9c..0000000 --- a/lesson-jenkins/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/lesson-jenkins/hello-node-app/test.js b/lesson-jenkins/hello-node-app/test.js deleted file mode 100644 index 71772b3..0000000 --- a/lesson-jenkins/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-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`. + diff --git a/lesson-rancher/README.md b/lesson-rancher/README.md index c893c2d..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 "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 ```