-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mongodb apb #106
Open
aweiteka
wants to merge
4
commits into
fusor:master
Choose a base branch
from
aweiteka:mongodb
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
mongodb apb #106
Changes from 2 commits
Commits
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 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,8 @@ | ||
FROM ansibleplaybookbundle/apb-base | ||
|
||
LABEL "com.redhat.apb.version"="0.1.0" | ||
|
||
COPY provision.yml deprovision.yml test.yml /opt/apb/actions/ | ||
COPY roles /opt/ansible/roles | ||
RUN chmod -R g=u /opt/{ansible,apb} | ||
USER apb |
This file contains 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,52 @@ | ||
CONTEXT = ansibleplaybookbundle | ||
VERSION = v0.1 | ||
IMAGE_NAME = mongodb-apb | ||
DISTRO = centos7 | ||
REGISTRY = 172.30.174.0:5000 | ||
OC_USER = developer | ||
OC_PASS = developer | ||
APB_APP = mongodb | ||
APB_SPEC = `base64 --wrap=0 apb.yml` | ||
IMAGE = ${CONTEXT}/${IMAGE_NAME}:${DISTRO}-${VERSION} | ||
|
||
ifneq ($(shell oc whoami . 2> /dev/null; echo $$?), 0) | ||
loggedin = $(shell oc login -u ${OC_USER} -p ${OC_PASS}) | ||
endif | ||
ifndef project | ||
export project = $(shell oc project -q) | ||
endif | ||
|
||
all: localtest localteardown localbuild push | ||
|
||
.PHONY: localbuild | ||
localbuild: | ||
docker build --no-cache \ | ||
--label "com.redhat.apb.version=${VERSION}" \ | ||
--label "com.redhat.apb.spec=${APB_SPEC}" \ | ||
-t ${CONTEXT}/${IMAGE_NAME}:${DISTRO}-${VERSION} \ | ||
-t ${CONTEXT}/${IMAGE_NAME} . | ||
|
||
.PHONY: push | ||
push: | ||
docker login -u ${OC_USER} -p `oc whoami -t` ${REGISTRY} | ||
docker tag ${CONTEXT}/${IMAGE_NAME}:${DISTRO}-${VERSION} \ | ||
${REGISTRY}/${project}/${IMAGE_NAME} | ||
docker push ${REGISTRY}/${project}/${IMAGE_NAME} | ||
|
||
.PHONY: buildopenshift | ||
buildopenshift: | ||
oc patch bc/${APB_APP} --patch="{\"spec\": {\"output\": {\"imageLabels\":[{\"name\":\"com.redhat.apb.spec\", \"value\": \"${APB_SPEC}\"}]}}}" ${project} | ||
oc start-build ${APB_APP} -n ${project} | ||
|
||
test: localtest | ||
|
||
.PHONY: localtest | ||
localtest: | ||
ANSIBLE_STRATEGY=debug | ||
ansible-playbook provision.yml --extra-vars namespace=${project} | ||
|
||
.PHONY: localteardown | ||
localteardown: | ||
ANSIBLE_STRATEGY=debug | ||
ansible-playbook deprovision.yml --extra-vars namespace=${project} | ||
|
This file contains 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,56 @@ | ||
name: mongodb-apb | ||
image: ansibleplaybookbundle/mongodb-apb | ||
description: This template provides a standalone MongoDB server with a database created. The database is stored on persistent storage. The database name, username, and password are chosen via parameters when provisioning this service. | ||
bindable: True | ||
async: true | ||
metadata: | ||
documentationUrl: https://access.redhat.com | ||
displayName: MongoDB (Persistent) | ||
console.openshift.io/iconClass: icon-mongodb | ||
longDescription: This template provides a standalone MongoDB server with a database created. The database is stored on persistent storage. The database name, username, and password are chosen via parameters when provisioning this service. | ||
plans: | ||
- name: default | ||
description: This default plan deploys mongodb | ||
free: true | ||
metadata: | ||
displayName: Default | ||
longDescription: This plan deploys Mongodb | ||
cost: $0.00 | ||
parameters: | ||
- name: memory_limit | ||
default: 512Mi | ||
title: Maximum amount of memory the container can use. | ||
type: string | ||
- name: namespace | ||
default: | ||
title: The OpenShift Namespace where the ImageStream resides. | ||
type: string | ||
- name: database_service_name | ||
default: mongodb | ||
title: The name of the OpenShift Service exposed for the database. | ||
type: string | ||
- name: mongodb_user | ||
default: | ||
title: Username for MongoDB user that will be used for accessing the database. | ||
type: string | ||
- name: mongodb_password | ||
default: | ||
title: Password for the MongoDB connection user. | ||
type: string | ||
- name: mongodb_database | ||
default: sampledb | ||
title: Name of the MongoDB database accessed. | ||
type: string | ||
- name: mongodb_admin_password | ||
default: | ||
title: Password for the database admin user. | ||
type: string | ||
- name: volume_capacity | ||
default: 1Gi | ||
title: Volume space available for data, e.g. 512Mi, 2Gi. | ||
type: string | ||
- name: mongodb_version | ||
default: 3.2 | ||
title: Version of MongoDB image to be used (2.4, 2.6, 3.2 or latest). | ||
type: string | ||
|
This file contains 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,11 @@ | ||
- name: Remove mongodb-apb from openshift | ||
hosts: localhost | ||
gather_facts: false | ||
connection: local | ||
vars: | ||
state: absent | ||
roles: | ||
- role: ansible.kubernetes-modules | ||
install_python_requirements: no | ||
- role: mongodb-apb-openshift | ||
playbook_debug: false |
This file contains 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 @@ | ||
mongodb_admin_password: "{{ lookup('password', '/tmp/pass chars=ascii_letters,digits') }}" | ||
mongodb_password: "{{ lookup('password', '/tmp/pass chars=ascii_letters,digits') }}" | ||
mongodb_user: "admin" | ||
volume_capacity: "1Gi" | ||
mongodb_version: "3.2" | ||
state: present | ||
image: "centos/mongodb-{{ mongodb_version | replace('.', '') }}-centos7" | ||
_apb_plan_id: default | ||
database_service_name: mongodb | ||
mongodb_database: sampledb |
This file contains 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,21 @@ | ||
- name: Deploy mongodb-apb to openshift | ||
hosts: localhost | ||
gather_facts: false | ||
connection: local | ||
vars: | ||
- mongodb_admin_password: "{{ lookup('password', '/tmp/pass chars=ascii_letters,digits') }}" | ||
- mongodb_password: "{{ lookup('password', '/tmp/pass chars=ascii_letters,digits') }}" | ||
- mongodb_user: "admin" | ||
- volume_capacity: "1Gi" | ||
- mongodb_version: "3.2" | ||
- state: present | ||
- image: "centos/mongodb-{{ mongodb_version | replace('.', '') }}-centos7" | ||
- _apb_plan_id: default | ||
- database_service_name: mongodb | ||
- mongodb_database: sampledb | ||
roles: | ||
- role: ansible.kubernetes-modules | ||
install_python_requirements: no | ||
- role: mongodb-apb-openshift | ||
playbook_debug: false | ||
|
This file contains 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,60 @@ | ||
- name: set development deployment config state to {{ state }} | ||
openshift_v1_deployment_config: | ||
name: mongodb | ||
namespace: '{{ namespace }}' | ||
labels: | ||
app: mongodb-apb | ||
service: mongodb | ||
replicas: 1 | ||
selector: | ||
app: mongodb-apb | ||
service: mongodb | ||
strategy_type: Rolling | ||
strategy_rolling_params: | ||
interval_seconds: 1 | ||
max_surge: 25% | ||
max_unavailable: 25% | ||
timeout_seconds: 600 | ||
update_period_seconds: 1 | ||
spec_template_metadata_labels: | ||
app: mongodb-apb | ||
service: mongodb | ||
containers: | ||
- env: | ||
- name: MONGODB_ADMIN_PASSWORD | ||
value: '{{ mongodb_admin_password }}' | ||
- name: MONGODB_PASSWORD | ||
value: '{{ mongodb_password }}' | ||
- name: MONGODB_USER | ||
value: '{{ mongodb_user }}' | ||
- name: MONGODB_DATABASE | ||
value: '{{ mongodb_database }}' | ||
image: '{{ image }}' | ||
image_pull_policy: IfNotPresent | ||
liveness_probe: | ||
initial_delay_seconds: 30 | ||
tcp_socket: | ||
port: 27017 | ||
timeout_seconds: 1 | ||
readiness_probe: | ||
exec: | ||
command: | ||
- "/bin/sh" | ||
- "-i" | ||
- "-c" | ||
- "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\"" | ||
initial_delay_seconds: 3 | ||
timeout_seconds: 1 | ||
name: mongodb | ||
ports: | ||
- container_port: 27017 | ||
protocol: TCP | ||
termination_message_path: /dev/termination-log | ||
working_dir: / | ||
dns_policy: ClusterFirst | ||
restart_policy: Always | ||
termination_grace_period_seconds: 30 | ||
test: false | ||
triggers: | ||
- type: ConfigChange | ||
state: "{{ state }}" |
This file contains 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,56 @@ | ||
- name: set service state to {{ state }} | ||
k8s_v1_service: | ||
name: mongodb | ||
namespace: "{{ namespace }}" | ||
labels: | ||
app: mongodb-apb | ||
service: mongodb | ||
selector: | ||
app: mongodb-apb | ||
service: mongodb | ||
ports: | ||
- name: port-27017 | ||
port: 27017 | ||
protocol: TCP | ||
target_port: 27017 | ||
state: "{{ state }}" | ||
register: mongodb_service | ||
|
||
- name: scale deployment down | ||
openshift_v1_deployment_config: | ||
name: mongodb | ||
namespace: "{{ namespace }}" | ||
replicas: 0 | ||
state: present | ||
selector: | ||
app: mongodb-apb | ||
service: mongodb | ||
when: state == "absent" | ||
|
||
- include: dev.yml | ||
when: _apb_plan_id == "default" | ||
|
||
- name: delete replication controller | ||
k8s_v1_replication_controller: | ||
name: mongodb-1 | ||
namespace: "{{ namespace }}" | ||
state: absent | ||
when: state == "absent" | ||
|
||
- name: Wait for mongodb to come up | ||
wait_for: | ||
port: 27017 | ||
host: "{{ mongodb_service.service.spec.cluster_ip }}" | ||
timeout: 300 | ||
when: state == "present" | ||
|
||
#- name: encode bind credentials | ||
# asb_encode_binding: | ||
# fields: | ||
# DB_TYPE: mongodb | ||
# DB_HOST: mongodb | ||
# DB_PORT: "27017" | ||
# DB_USER: "{{ mongodb_user }}" | ||
# DB_PASSWORD: "{{ mongodb_password }}" | ||
# DB_NAME: "{{ mongodb_database }}" | ||
# when: state == "present" |
This file contains 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,12 @@ | ||
- name: Test mongodb-apb on openshift | ||
hosts: localhost | ||
gather_facts: false | ||
connection: local | ||
vars: | ||
target: all | ||
tasks: | ||
- name: Test entrypoint | ||
make: | ||
chdir: . | ||
target: "{{ target }}" | ||
become: yes |
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.
If there is no default I would just leave it off rather than blank.