This repository was archived by the owner on Mar 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Add jenkins example with nulecule specification #8
Open
praveenkumar
wants to merge
3
commits into
projectatomic:master
Choose a base branch
from
praveenkumar:jenkins-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| FROM projectatomic/atomicapp:0.1.12 | ||
|
|
||
| MAINTAINER Praveen Kumar <prkumar@redhat.com> | ||
|
|
||
| LABEL io.projectatomic.nulecule.specversion="0.0.2" \ | ||
| io.projectatomic.nulecule.providers="kubernetes,docker"\ | ||
| Build="docker build --rm --tag test/jenkins-atomicapp ." | ||
|
|
||
| ADD /Nulecule /Dockerfile README.md gpl-3.0.txt /application-entity/ | ||
| ADD /artifacts /application-entity/artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| specversion: 0.0.2 | ||
| id: jenkins-atomicapp | ||
|
|
||
| metadata: | ||
| name: Jenkins App | ||
| appversion: 1.635 | ||
| description: Jenkins is an open-source continuous integration server. | ||
| graph: | ||
| - name: jenkins | ||
| params: | ||
| - name: image | ||
| description: Jenkins image to be used | ||
| default: kumarpraveen/centos-jenkins:latest | ||
| - name: replicas | ||
| description: number of replica to be used | ||
| default: 1 | ||
| constraints: | ||
| allowed_patterns: "^[1-9]+$" | ||
| description: Valid value for replica is a natural number (positive integer) | ||
| - name: NODE_PORT | ||
| description: Node port where Jenkins HTTP service will be forwarded to | ||
| default: 30001 | ||
| constraints: | ||
| allowed_patterns: "^(3[0-1][0-9][0-9][0-9]|32[0-5][0-9][0-9]|326[0-5][0-9]|3266[0-7])$" | ||
| description: The valid range for node port is 30000-32667 for Kubernetes provider | ||
| artifacts: | ||
| kubernetes: | ||
| - file://artifacts/kubernetes/jenkins-rc.json | ||
| - file://artifacts/kubernetes/jenkins-http-service.json | ||
| docker: | ||
| - file://artifacts/docker/jenkins-container-run | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| This is an atomicapp application based on the nulecule specification. Docker and Kubernetes are the supported providers. You'll need to run this from a workstation that has the [atomic](https://github.com/projectatomic/atomic) command and kubectl client that can connect to a kubernetes master. | ||
|
|
||
| It is a single tier application based on jenkins. | ||
|
|
||
| ### Option 1: Interactive | ||
|
|
||
| Run the image. It will automatically use kubernetes as the orchestration provider. It will prompt for all parameters in the Nulecule file that do not have default values: | ||
|
|
||
| $ [sudo] atomic run projectatomic/jenkins-centos7-atomicapp | ||
|
|
||
| ## Option 2: Unattended | ||
|
|
||
| 1. Create the file `answers.conf` with these contents: | ||
|
|
||
| This sets up the values for the configurable parameters and indicates that kubernetes should be the orchestration provider. | ||
|
|
||
| [general] | ||
| namespace = default | ||
| provider = kubernetes | ||
|
|
||
| [jenkins] | ||
| image=kumarpraveen/centos-jenkins:latest | ||
| # port on the node where Jenkins over HTTP will be accessible - valid range 30000-32667 | ||
| NODE_PORT=30001 | ||
|
|
||
|
|
||
| 1. Run the application from the current working directory | ||
|
|
||
| $ [sudo] atomic run projectatomic/jenkins-centos7-atomicapp | ||
|
|
||
| ### Option 3: Install and Run | ||
|
|
||
| You may want to download the application, review the configuraton and parameters as specified in the Nulecule file, and edit the answerfile before running the application. | ||
|
|
||
| 1. Download the application files using `atomic install` | ||
|
|
||
| [sudo] atomic install projectatomic/jenkins-centos7-atomicapp | ||
|
|
||
| 1. Rename `answers.conf.sample` | ||
|
|
||
| mv answers.conf.sample answers.conf | ||
|
|
||
| 1. Edit `answers.conf`, review files if desired and then run | ||
|
|
||
| $ [sudo] atomic run projectatomic/jenkins-centos7-atomicapp | ||
|
|
||
| Note: You can change the provider to `docker` and the app will be deployed using `docker`. | ||
|
|
||
| ## Test | ||
| Any of these approaches should create kubernetes replication controllers, pods and services. | ||
|
|
||
| Jenkins is web app, to test if its functioning we can access it in browser. | ||
| We have configured the app on ADB port 30001 (see answer.conf). You can access | ||
| the app using the IP of ADB box at port 30001 or by forwarding the port 30001 of ADB box to | ||
| host machine port. | ||
|
|
||
| To test out if app is running and intialized properly (run following inside ADB) | ||
| ``` | ||
| $ kubectl get pods | ||
| NAME READY STATUS RESTARTS AGE | ||
| jenkins-0nax4 1/1 Running 0 15m | ||
|
|
||
| $ kubectl logs jenkins-0nax4 | ||
| /usr/lib/python2.7/site-packages/supervisor/options.py:296: UserWarning: | ||
| Supervisord is running as root and it is searching for its configuration file in | ||
| default locations (including its current working directory); you probably want | ||
| to specify a "-c" argument specifying an absolute path to a configuration file | ||
| for improved security. | ||
| 'Supervisord is running as root and it is searching ' | ||
| 2015-10-30 12:06:31,194 CRIT Supervisor running as root (no user in config | ||
| file) | ||
| 2015-10-30 12:06:31,194 WARN No file matches via include | ||
| "/etc/supervisord.d/*.ini" | ||
| 2015-10-30 12:06:31,283 INFO RPC interface 'supervisor' initialized | ||
| 2015-10-30 12:06:31,284 CRIT Server 'unix_http_server' running without any | ||
| HTTP authentication checking | ||
| 2015-10-30 12:06:31,295 INFO supervisord started with pid 1 | ||
| 2015-10-30 12:06:32,314 INFO spawned: 'jenkins' with pid 8 | ||
| 2015-10-30 12:06:33,637 INFO success: jenkins entered RUNNING state, process | ||
| has stayed up for > than 1 seconds (startsecs) | ||
| 2015-10-30 12:06:36,798 INFO exited: jenkins (exit status 0; expected) | ||
|
|
||
| ``` | ||
|
|
||
| To forward port `30001` of ADB box to host machine port `30001`, add following line your Vagrantfile | ||
|
|
||
| ``` | ||
| config.vm.network "forwarded_port", guest: 30001, host: 30001, auto_correct: true | ||
|
|
||
| ``` | ||
|
|
||
| and run following command to apply changes in updated Vagrantfile | ||
|
|
||
| ``` | ||
| vagrant reload | ||
| ``` | ||
|
|
||
| Observe logs as shown above if app is configured and ready to accept connections, once it is ready you should be able to access the app at host browser using address | ||
|
|
||
| ``` | ||
| http://127.0.0.1:30001 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [general] | ||
| namespace = default | ||
| provider = kubernetes | ||
| # provider = docker | ||
|
|
||
| [jenkins] | ||
| image=kumarpraveen/centos-jenkins:latest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same image here... can we use openshift's? |
||
| # port on the node where Jenkins over HTTP will be accessible - valid range | ||
| # 30000-32667 | ||
| NODE_PORT=30001 | ||
1 change: 1 addition & 0 deletions
1
jenkins-centos7-atomicapp/artifacts/docker/jenkins-container-run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| docker run --name=jenkins -d --publish $NODE_PORT:8080 $image |
20 changes: 20 additions & 0 deletions
20
jenkins-centos7-atomicapp/artifacts/kubernetes/jenkins-http-service.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "apiVersion": "v1", | ||
| "kind": "Service", | ||
| "metadata": { | ||
| "name": "jenkins" | ||
| }, | ||
| "spec": { | ||
| "type": "NodePort", | ||
| "ports": [ | ||
| { | ||
| "port": 8080, | ||
| "protocol": "TCP", | ||
| "NodePort": $NODE_PORT | ||
| } | ||
| ], | ||
| "selector": { | ||
| "app": "jenkins" | ||
| } | ||
| } | ||
| } |
47 changes: 47 additions & 0 deletions
47
jenkins-centos7-atomicapp/artifacts/kubernetes/jenkins-rc.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "kind": "ReplicationController", | ||
| "apiVersion": "v1", | ||
| "metadata": { | ||
| "name": "jenkins" | ||
| }, | ||
| "spec": { | ||
| "replicas": "$replicas", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does replicas > 1 handle storage? |
||
| "selector": { | ||
| "app": "jenkins" | ||
| }, | ||
| "template": { | ||
| "metadata": { | ||
| "labels": { | ||
| "app": "jenkins" | ||
| }, | ||
| "name": "jenkins" | ||
| }, | ||
| "spec": { | ||
| "containers": [ | ||
| { | ||
| "name": "jenkins", | ||
| "image": "$image", | ||
| "ports": [ | ||
| { | ||
| "name": "jenkins-http", | ||
| "containerPort": 8080 | ||
| } | ||
| ], | ||
| "volumeMounts": [ | ||
| { | ||
| "mountPath": "/var/lib/jenkins", | ||
| "name": "jenkins-persistent-storage" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "volumes": [ | ||
| { | ||
| "emptyDir": {}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe worth adding a comment that data is lost after container terminated, persistent-storage suggest something different?! or am I wrong? hmm... is it simply bound to the host where to pod ran on initially? |
||
| "name": "jenkins-persistent-storage" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you check if you can use this: https://hub.docker.com/r/openshift/jenkins-1-centos7/