Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions jenkins-centos7-atomicapp/Dockerfile
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
32 changes: 32 additions & 0 deletions jenkins-centos7-atomicapp/Nulecule
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
Copy link
Contributor

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/

- 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
102 changes: 102 additions & 0 deletions jenkins-centos7-atomicapp/README.md
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
```
10 changes: 10 additions & 0 deletions jenkins-centos7-atomicapp/answers.conf.sample
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run --name=jenkins -d --publish $NODE_PORT:8080 $image
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 jenkins-centos7-atomicapp/artifacts/kubernetes/jenkins-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"kind": "ReplicationController",
"apiVersion": "v1",
"metadata": {
"name": "jenkins"
},
"spec": {
"replicas": "$replicas",
Copy link
Contributor

Choose a reason for hiding this comment

The 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": {},
Copy link
Contributor

Choose a reason for hiding this comment

The 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"
}
]
}
}
}
}
Loading