├── test-requirements.txt
├── images
└── architecture.png
├── scripts
├── quickstart.sh
└── deploy.sh
├── .gitignore
├── CONTRIBUTING.md
├── tests
├── test-minikube.sh
└── test-kubernetes.sh
├── .travis.yml
├── kubernetes
├── local-volumes.yaml
├── postgres.yaml
└── drupal.yaml
├── .yamllint.yml
├── .bluemix
├── pipeline.yml
├── toolchain.yml
├── icon.svg
├── deploy.json
└── toolchain.svg
├── MAINTAINERS.md
├── README.md
└── LICENSE
/test-requirements.txt:
--------------------------------------------------------------------------------
1 | yamllint
2 |
--------------------------------------------------------------------------------
/images/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/drupal-on-kubernetes-sample/HEAD/images/architecture.png
--------------------------------------------------------------------------------
/scripts/quickstart.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | kubectl create -f kubernetes/local-volumes.yaml
4 | kubectl create -f kubernetes/postgres.yaml
5 | kubectl create -f kubernetes/drupal.yaml
6 | kubectl get nodes
7 | kubectl get svc drupal
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore Vim files
2 | [._]*.s[a-w][a-z]
3 | [._]s[a-w][a-z]
4 | Session.vim
5 | .netrwhist
6 | *~
7 | tags
8 |
9 | # Ignore macOS files
10 | *.DS_Store
11 | .AppleDouble
12 | .LSOverride
13 | ._*
14 | .DocumentRevisions-V100
15 | .fseventsd
16 | .Spotlight-V100
17 | .TemporaryItems
18 | .Trashes
19 | .VolumeIcon.icns
20 | .com.apple.timemachine.donotpresent
21 | .AppleDB
22 | .AppleDesktop
23 | Network Trash Folder
24 | Temporary Items
25 | .apdisk
26 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | This is an open source project, and we appreciate your help!
4 |
5 | We use the GitHub issue tracker to discuss new features and non-trivial bugs.
6 |
7 | In addition to the issue tracker, [#journeys on
8 | Slack](https://dwopen.slack.com) is the best way to get into contact with the
9 | project's maintainers.
10 |
11 | To contribute code, documentation, or tests, please submit a pull request to
12 | the GitHub repository. Generally, we expect two maintainers to review your pull
13 | request before it is approved for merging. For more details, see the
14 | [MAINTAINERS](MAINTAINERS.md) page.
15 |
--------------------------------------------------------------------------------
/tests/test-minikube.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -ex
2 |
3 | # shellcheck disable=SC1090
4 | source "$(dirname "$0")"/../pattern-ci/scripts/resources.sh
5 |
6 | kubectl_deploy() {
7 | echo "Running scripts/quickstart.sh"
8 | "$(dirname "$0")"/../scripts/quickstart.sh
9 | }
10 |
11 | verify_deploy(){
12 | echo "Verifying deployment was successful"
13 | if ! sleep 1 && curl -sS "$(kubectl get svc drupal | grep drupal | awk '{ print $2 }')":30080; then
14 | test_failed "$0"
15 | fi
16 | }
17 |
18 | main(){
19 | if ! kubectl_deploy; then
20 | test_failed "$0"
21 | elif ! verify_deploy; then
22 | test_failed "$0"
23 | else
24 | test_passed "$0"
25 | fi
26 | }
27 |
28 | main "$@"
29 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: 2.7
4 | cache: pip
5 | sudo: required
6 |
7 | before_install:
8 | - sudo apt-get install shellcheck
9 | - pip install -U -r test-requirements.txt
10 | - git clone --single-branch --depth=1 --branch update-minikube https://github.com/IBM/pattern-ci
11 |
12 | before_script:
13 | - "./pattern-ci/tests/shellcheck-lint.sh"
14 | - "./pattern-ci/tests/yaml-lint.sh"
15 |
16 | jobs:
17 | include:
18 | - install: ./pattern-ci/scripts/install-minikube.sh
19 | script: ./tests/test-minikube.sh
20 | - install:
21 | - ./pattern-ci/scripts/install-ibmcloud.sh
22 | - ./pattern-ci/scripts/bx-auth.sh
23 | script: ./tests/test-kubernetes.sh
24 |
--------------------------------------------------------------------------------
/kubernetes/local-volumes.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: v1
3 | kind: PersistentVolume
4 | metadata:
5 | name: local-volume-1
6 | labels:
7 | type: local
8 | spec:
9 | capacity:
10 | storage: 10Gi
11 | accessModes:
12 | - ReadWriteOnce
13 | hostPath:
14 | path: /tmp/data/pv-1
15 | persistentVolumeReclaimPolicy: Recycle
16 | ---
17 | apiVersion: v1
18 | kind: PersistentVolume
19 | metadata:
20 | name: local-volume-2
21 | labels:
22 | type: local
23 | spec:
24 | capacity:
25 | storage: 10Gi
26 | accessModes:
27 | - ReadWriteOnce
28 | hostPath:
29 | path: /tmp/data/pv-2
30 | persistentVolumeReclaimPolicy: Recycle
31 | ---
32 | apiVersion: v1
33 | kind: PersistentVolume
34 | metadata:
35 | name: local-volume-3
36 | labels:
37 | type: local
38 | spec:
39 | capacity:
40 | storage: 10Gi
41 | accessModes:
42 | - ReadWriteOnce
43 | hostPath:
44 | path: /tmp/data/pv-3
45 | persistentVolumeReclaimPolicy: Recycle
46 |
--------------------------------------------------------------------------------
/scripts/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Create Drupal"
4 | IP_ADDR=$(bx cs workers "$CLUSTER_NAME" | grep Ready | awk '{ print $2 }')
5 | if [[ -z "$IP_ADDR" ]]; then
6 | echo "$CLUSTER_NAME not created or workers not ready"
7 | exit 1
8 | fi
9 |
10 | echo -e "Configuring vars"
11 | if ! exp=$(bx cs cluster-config "$CLUSTER_NAME" | grep export); then
12 | echo "Cluster $CLUSTER_NAME not created or not ready."
13 | exit 1
14 | fi
15 | eval "$exp"
16 |
17 | echo -e "Deleting previous version of Drupal if it exists"
18 | kubectl delete --ignore-not-found=true svc,pvc,deployment -l app=drupal
19 | kubectl delete --ignore-not-found=true -f kubernetes/local-volumes.yaml
20 |
21 | echo -e "Creating pods"
22 | kubectl create -f kubernetes/local-volumes.yaml
23 | kubectl create -f kubernetes/postgres.yaml
24 | kubectl create -f kubernetes/drupal.yaml
25 | kubectl get svc drupal
26 |
27 | echo "" && echo "View your Drupal website at http://$IP_ADDR:30080"
28 |
29 | echo "Note: Your Drupal may take up to 5 minutes to be fully functioning"
30 |
--------------------------------------------------------------------------------
/.yamllint.yml:
--------------------------------------------------------------------------------
1 | ---
2 | rules:
3 | braces:
4 | min-spaces-inside: 0
5 | max-spaces-inside: 0
6 | min-spaces-inside-empty: 0
7 | max-spaces-inside-empty: 0
8 | brackets:
9 | min-spaces-inside: 0
10 | max-spaces-inside: 0
11 | min-spaces-inside-empty: 0
12 | max-spaces-inside-empty: 0
13 | colons:
14 | max-spaces-before: 0
15 | max-spaces-after: 1
16 | commas:
17 | max-spaces-before: 0
18 | min-spaces-after: 1
19 | max-spaces-after: 1
20 | comments:
21 | require-starting-space: true
22 | min-spaces-from-content: 2
23 | comments-indentation: enable
24 | document-end: disable
25 | document-start:
26 | present: true
27 | empty-lines:
28 | max: 2
29 | max-start: 0
30 | max-end: 0
31 | hyphens:
32 | max-spaces-after: 1
33 | indentation:
34 | spaces: consistent
35 | indent-sequences: true
36 | check-multi-line-strings: false
37 | key-duplicates: enable
38 | line-length:
39 | max: 80
40 | allow-non-breakable-words: true
41 | allow-non-breakable-inline-mappings: true
42 | level: warning
43 | new-line-at-end-of-file: enable
44 | new-lines:
45 | type: unix
46 | trailing-spaces: enable
47 | truthy: enable
48 |
--------------------------------------------------------------------------------
/kubernetes/postgres.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: postgresql
6 | labels:
7 | app: drupal
8 | spec:
9 | ports:
10 | - port: 5432
11 | selector:
12 | app: drupal
13 | tier: postgreSQL
14 | ---
15 | apiVersion: v1
16 | kind: PersistentVolumeClaim
17 | metadata:
18 | name: postgres-claim
19 | labels:
20 | app: drupal
21 | spec:
22 | accessModes:
23 | - ReadWriteOnce
24 | resources:
25 | requests:
26 | storage: 10Gi
27 | ---
28 | apiVersion: extensions/v1beta1
29 | kind: Deployment
30 | metadata:
31 | name: postgresql
32 | labels:
33 | app: drupal
34 | spec:
35 | strategy:
36 | type: Recreate
37 | template:
38 | metadata:
39 | labels:
40 | app: drupal
41 | tier: postgreSQL
42 | spec:
43 | containers:
44 | - image: postgres:latest
45 | name: postgresql
46 | env:
47 | - name: POSTGRES_USER
48 | value: drupal
49 | - name: POSTGRES_DB
50 | value: drupal_production
51 | - name: POSTGRES_PASSWORD
52 | value: drupal
53 | ports:
54 | - containerPort: 5432
55 | name: postgresql
56 | volumeMounts:
57 | - name: postgresql
58 | mountPath: /var/lib/postgresql/data
59 | volumes:
60 | - name: postgresql
61 | persistentVolumeClaim:
62 | claimName: postgres-claim
63 |
--------------------------------------------------------------------------------
/kubernetes/drupal.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: drupal
6 | labels:
7 | app: drupal
8 | spec:
9 | type: NodePort
10 | ports:
11 | - port: 80
12 | nodePort: 30080
13 | selector:
14 | app: drupal
15 | tier: frontend
16 | ---
17 | apiVersion: v1
18 | kind: PersistentVolumeClaim
19 | metadata:
20 | name: drupal-claim
21 | labels:
22 | app: drupal
23 | spec:
24 | accessModes:
25 | - ReadWriteOnce
26 | resources:
27 | requests:
28 | storage: 10Gi
29 | ---
30 | apiVersion: extensions/v1beta1
31 | kind: Deployment
32 | metadata:
33 | name: drupal
34 | labels:
35 | app: drupal
36 | spec:
37 | strategy:
38 | type: Recreate
39 | template:
40 | metadata:
41 | labels:
42 | app: drupal
43 | tier: frontend
44 | spec:
45 | containers:
46 | - image: drupal:latest
47 | name: drupal
48 | ports:
49 | - containerPort: 30080
50 | name: drupal
51 | volumeMounts:
52 | - name: drupal
53 | mountPath: /var/www/html/modules
54 | subPath: modules
55 | - name: drupal
56 | mountPath: /var/www/html/profiles
57 | subPath: profiles
58 | - name: drupal
59 | mountPath: /var/www/html/themes
60 | subPath: themes
61 | volumes:
62 | - name: drupal
63 | persistentVolumeClaim:
64 | claimName: drupal-claim
65 |
--------------------------------------------------------------------------------
/.bluemix/pipeline.yml:
--------------------------------------------------------------------------------
1 | ---
2 | stages:
3 | - name: BUILD
4 | inputs:
5 | - type: git
6 | branch: master
7 | service: ${SAMPLE_REPO}
8 | triggers:
9 | - type: commit
10 | jobs:
11 | - name: Build
12 | type: builder
13 | artifact_dir: ''
14 | build_type: shell
15 | script: |-
16 | #!/bin/bash
17 | bash -n *.sh
18 | - name: DEPLOY
19 | inputs:
20 | - type: job
21 | stage: BUILD
22 | job: Build
23 | dir_name: null
24 | triggers:
25 | - type: stage
26 | properties:
27 | - name: BLUEMIX_USER
28 | type: text
29 | value: ${BLUEMIX_USER}
30 | - name: BLUEMIX_PASSWORD
31 | type: secure
32 | value: ${BLUEMIX_PASSWORD}
33 | - name: BLUEMIX_ACCOUNT
34 | type: secure
35 | value: ${BLUEMIX_ACCOUNT}
36 | - name: CLUSTER_NAME
37 | type: text
38 | value: ${CLUSTER_NAME}
39 | - name: API_KEY
40 | type: secure
41 | value: ${API_KEY}
42 | jobs:
43 | - name: Deploy
44 | type: deployer
45 | target:
46 | region_id: ${PROD_REGION_ID}
47 | api_key: ${API_KEY}
48 | kubernetes_cluster: ${CLUSTER_NAME}
49 | application: Pipeline
50 | script: |
51 | #!/bin/bash
52 | ./scripts/deploy.sh
53 | hooks:
54 | - enabled: true
55 | label: null
56 | ssl_enabled: false
57 | url: https://devops-api-integration.stage1.ng.bluemix.net/v1/messaging/webhook/publish
58 |
--------------------------------------------------------------------------------
/.bluemix/toolchain.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Deploy Drupal on Kubernetes in Bluemix"
3 | description: "Toolchain to deploy Drupal on Kubernetes in Bluemix"
4 | version: 0.1
5 | image: data:image/svg+xml;base64,$file(toolchain.svg,base64)
6 | icon: data:image/svg+xml;base64,$file(icon.svg,base64)
7 | required:
8 | - deploy
9 | - sample-repo
10 |
11 | # Github repos
12 | sample-repo:
13 | service_id: githubpublic
14 | parameters:
15 | repo_name: "{{name}}"
16 | repo_url: https://github.com/IBM/drupal-on-kubernetes-sample
17 | type: clone
18 | has_issues: false
19 |
20 | # Pipelines
21 | sample-build:
22 | service_id: pipeline
23 | parameters:
24 | name: "{{name}}"
25 | ui-pipeline: true
26 | configuration:
27 | content: $file(pipeline.yml)
28 | env:
29 | SAMPLE_REPO: "sample-repo"
30 | CF_APP_NAME: "{{deploy.parameters.prod-app-name}}"
31 | PROD_SPACE_NAME: "{{deploy.parameters.prod-space}}"
32 | PROD_ORG_NAME: "{{deploy.parameters.prod-organization}}"
33 | PROD_REGION_ID: "{{deploy.parameters.prod-region}}"
34 | BLUEMIX_USER: "{{deploy.parameters.bluemix-user}}"
35 | BLUEMIX_PASSWORD: "{{deploy.parameters.bluemix-password}}"
36 | API_KEY: "{{deploy.parameters.bluemix-api-key}}"
37 | BLUEMIX_ACCOUNT: "{{deploy.parameters.bluemix-cluster-account}}"
38 | CLUSTER_NAME: "{{deploy.parameters.bluemix-cluster-name}}"
39 | execute: true
40 | services: ["sample-repo"]
41 | hidden: [form, description]
42 |
43 | # Deployment
44 | deploy:
45 | schema:
46 | $ref: deploy.json
47 | service-category: pipeline
48 | parameters:
49 | prod-app-name: "{{sample-repo.parameters.repo_name}}"
50 |
--------------------------------------------------------------------------------
/tests/test-kubernetes.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # This script is intended to be run by Travis CI. If running elsewhere, invoke
4 | # it with: TRAVIS_PULL_REQUEST=false [path to script]
5 |
6 | # shellcheck disable=SC1090
7 | source "$(dirname "$0")"/../pattern-ci/scripts/resources.sh
8 |
9 | kubeclt_clean() {
10 | echo "Cleaning cluster"
11 | kubectl delete pvc,deployment,service,replicaset -l app=drupal
12 | sleep 30s
13 | kubectl delete pv local-volume-1 local-volume-2 local-volume-3
14 | }
15 |
16 | kubectl_config() {
17 | echo "Configuring kubectl"
18 | #shellcheck disable=SC2091
19 | $(bx cs cluster-config "$CLUSTER_NAME" | grep export)
20 | }
21 |
22 |
23 | kubectl_deploy() {
24 | kubeclt_clean
25 |
26 | echo "Running scripts/quickstart.sh"
27 | "$(dirname "$0")"/../scripts/quickstart.sh
28 |
29 | echo "Waiting for pods to be running"
30 | i=0
31 | while [[ $(kubectl get pods -l app=drupal | grep -c Running) -ne 2 ]]; do
32 | if [[ ! "$i" -lt 24 ]]; then
33 | echo "Timeout waiting on pods to be ready"
34 | test_failed "$0"
35 | fi
36 | sleep 10
37 | echo "...$i * 10 seconds elapsed..."
38 | ((i++))
39 | done
40 | echo "All pods are running"
41 |
42 | echo "Waiting for service to be available"
43 | sleep 120
44 | }
45 |
46 | verify_deploy(){
47 | echo "Verifying deployment was successful"
48 | IPS=$(bx cs workers "$CLUSTER_NAME" | awk '{ print $2 }' | grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
49 | for IP in $IPS; do
50 | if ! curl -sS "$IP":30080; then
51 | test_failed "$0"
52 | fi
53 | echo
54 | done
55 | }
56 |
57 | main(){
58 | is_pull_request "$0"
59 |
60 | if ! kubectl_config; then
61 | test_failed "$0"
62 | elif ! kubectl_deploy; then
63 | test_failed "$0"
64 | elif ! verify_deploy; then
65 | test_failed "$0"
66 | else
67 | test_passed "$0"
68 | fi
69 | }
70 |
71 | main "$@"
72 |
--------------------------------------------------------------------------------
/.bluemix/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
36 |
--------------------------------------------------------------------------------
/MAINTAINERS.md:
--------------------------------------------------------------------------------
1 | # Maintainers Guide
2 |
3 | This guide is intended for maintainers - anybody with commit access to one or
4 | more Code Pattern repositories.
5 |
6 | ## Methodology
7 |
8 | This repository does not have a traditional release management cycle, but
9 | should instead be maintained as a useful, working, and polished reference at
10 | all times. While all work can therefore be focused on the master branch, the
11 | quality of this branch should never be compromised.
12 |
13 | The remainder of this document details how to merge pull requests to the
14 | repositories.
15 |
16 | ## Merge approval
17 |
18 | The project maintainers use LGTM (Looks Good To Me) in comments on the pull
19 | request to indicate acceptance prior to merging. A change requires LGTMs from
20 | two project maintainers. If the code is written by a maintainer, the change
21 | only requires one additional LGTM.
22 |
23 | ## Reviewing Pull Requests
24 |
25 | We recommend reviewing pull requests directly within GitHub. This allows a
26 | public commentary on changes, providing transparency for all users. When
27 | providing feedback be civil, courteous, and kind. Disagreement is fine, so long
28 | as the discourse is carried out politely. If we see a record of uncivil or
29 | abusive comments, we will revoke your commit privileges and invite you to leave
30 | the project.
31 |
32 | During your review, consider the following points:
33 |
34 | ### Does the change have positive impact?
35 |
36 | Some proposed changes may not represent a positive impact to the project. Ask
37 | whether or not the change will make understanding the code easier, or if it
38 | could simply be a personal preference on the part of the author (see
39 | [bikeshedding](https://en.wiktionary.org/wiki/bikeshedding)).
40 |
41 | Pull requests that do not have a clear positive impact should be closed without
42 | merging.
43 |
44 | ### Do the changes make sense?
45 |
46 | If you do not understand what the changes are or what they accomplish, ask the
47 | author for clarification. Ask the author to add comments and/or clarify test
48 | case names to make the intentions clear.
49 |
50 | At times, such clarification will reveal that the author may not be using the
51 | code correctly, or is unaware of features that accommodate their needs. If you
52 | feel this is the case, work up a code sample that would address the pull
53 | request for them, and feel free to close the pull request once they confirm.
54 |
55 | ### Does the change introduce a new feature?
56 |
57 | For any given pull request, ask yourself "is this a new feature?" If so, does
58 | the pull request (or associated issue) contain narrative indicating the need
59 | for the feature? If not, ask them to provide that information.
60 |
61 | Are new unit tests in place that test all new behaviors introduced? If not, do
62 | not merge the feature until they are! Is documentation in place for the new
63 | feature? (See the documentation guidelines). If not do not merge the feature
64 | until it is! Is the feature necessary for general use cases? Try and keep the
65 | scope of any given component narrow. If a proposed feature does not fit that
66 | scope, recommend to the user that they maintain the feature on their own, and
67 | close the request. You may also recommend that they see if the feature gains
68 | traction among other users, and suggest they re-submit when they can show such
69 | support.
70 |
--------------------------------------------------------------------------------
/.bluemix/deploy.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "Sample Deploy Stage",
4 | "description": "sample toolchain",
5 | "longDescription": "The Delivery Pipeline automates continuous deployment.",
6 | "type": "object",
7 | "properties": {
8 | "prod-region": {
9 | "description": "The bluemix region",
10 | "type": "string"
11 | },
12 | "prod-organization": {
13 | "description": "The bluemix org",
14 | "type": "string"
15 | },
16 | "prod-space": {
17 | "description": "The bluemix space",
18 | "type": "string"
19 | },
20 | "prod-app-name": {
21 | "description": "The name of your Drupal app",
22 | "type": "string"
23 | },
24 | "bluemix-user": {
25 | "description": "Your Bluemix user ID",
26 | "type": "string"
27 | },
28 | "bluemix-password": {
29 | "description": "Your Bluemix Password",
30 | "type": "string"
31 | },
32 | "bluemix-api-key": {
33 | "description": "Required for **Federated ID** since Federated ID can't login with Bluemix user and password via Bluemix CLI. You can obtain your API_KEY via https://console.ng.bluemix.net/iam/#/apikeys by clicking **Create API key** (Each API key only can be viewed once).",
34 | "type": "string"
35 | },
36 | "bluemix-cluster-account": {
37 | "description": "The GUID of the Bluemix account where you created the cluster. Retrieve it with [bx iam accounts].",
38 | "type": "string"
39 | },
40 | "bluemix-cluster-name": {
41 | "description": "Your cluster name. Retrieve it with [bx cs clusters].",
42 | "type": "string"
43 | }
44 | },
45 | "required": ["prod-region", "prod-organization", "prod-space", "bluemix-cluster-name"],
46 | "anyOf": [
47 | {
48 | "required": ["bluemix-user", "bluemix-password", "bluemix-cluster-account"]
49 | },
50 | {
51 | "required": ["bluemix-api-key"]
52 | }
53 | ],
54 | "form": [
55 | {
56 | "type": "validator",
57 | "url": "/devops/setup/bm-helper/helper.html"
58 | },
59 | {
60 | "type": "text",
61 | "readonly": false,
62 | "title": "Bluemix User ID",
63 | "key": "bluemix-user"
64 | },{
65 | "type": "password",
66 | "readonly": false,
67 | "title": "Bluemix Password",
68 | "key": "bluemix-password"
69 | },{
70 | "type": "password",
71 | "readonly": false,
72 | "title": "Bluemix API Key (Optional)",
73 | "key": "bluemix-api-key"
74 | },{
75 | "type": "password",
76 | "readonly": false,
77 | "title": "Bluemix Cluster Account ID",
78 | "key": "bluemix-cluster-account"
79 | },{
80 | "type": "text",
81 | "readonly": false,
82 | "title": "Bluemix Cluster Name",
83 | "key": "bluemix-cluster-name"
84 | },
85 | {
86 | "type": "table",
87 | "columnCount": 4,
88 | "widths": ["15%", "28%", "28%", "28%"],
89 | "items": [
90 | {
91 | "type": "label",
92 | "title": ""
93 | },
94 | {
95 | "type": "label",
96 | "title": "Region"
97 | },
98 | {
99 | "type": "label",
100 | "title": "Organization"
101 | },
102 | {
103 | "type": "label",
104 | "title": "Space"
105 | },
106 | {
107 | "type": "label",
108 | "title": "Production stage"
109 | },
110 | {
111 | "type": "select",
112 | "key": "prod-region"
113 | },
114 | {
115 | "type": "select",
116 | "key": "prod-organization"
117 | },
118 | {
119 | "type": "select",
120 | "key": "prod-space",
121 | "readonly": false
122 | }
123 | ]
124 | }
125 | ]
126 | }
127 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/IBM/drupal-on-kubernetes-sample)
2 |
3 | # Deploy Drupal on Kubernetes
4 |
5 | In this Code Pattern, we will setup a Drupal site using Kubernetes and Postgres. Drupal is a popular free and open source content management system used as the backend for millions of web sites worldwide. By splitting out the services into containers, we have the ability to leverage the power of Kubernetes.
6 |
7 | When the reader has completed this Code Pattern, they will understand how to:
8 |
9 | * Configure an app running multiple containers in Kubernetes
10 | * Run a website hosted via Kubernetes
11 | * Use Kubernetes persistent volumes to maintain Drupal configurations between container restarts
12 |
13 | 
14 |
15 | ## Flow
16 |
17 | 1. User interacts with the Drupal web interface.
18 | 2. The Drupal container uses its persistent volume to store website data (but not content).
19 | 3. Drupal container connects to PostgreSQL container to access website content.
20 | 4. PostgreSQL container uses its persistent volume to store the database contents.
21 |
22 | ## Included components
23 |
24 | * [Kubernetes Cluster](https://cloud.ibm.com/docs/containers/container_index.html): Create and manage your own cloud infrastructure and use Kubernetes as your container orchestration engine.
25 | * [PostgreSQL](https://www.postgresql.org/): Sophisticated open-source Object-Relational DBMS supporting almost all SQL constructs.
26 |
27 | ## Featured technologies
28 |
29 | * [Cloud](https://developer.ibm.com/depmodels/cloud/): Accessing computer and information technology resources through the Internet.
30 |
31 | ## Watch the video
32 |
33 | [](https://youtu.be/fQY8q6CjU68)
34 |
35 | ## Steps
36 |
37 | [](https://cloud.ibm.com/devops/setup/deploy?repository=https://github.com/IBM/drupal-on-kubernetes-sample)
38 |
39 | Follow these steps to run Drupal on Kubernetes.
40 |
41 | 1. [Clone the repo](#1-clone-the-repo)
42 | 2. [Create Kubernetes cluster](#2-create-the-kubernetes-cluster)
43 | 1. [Locally](#2.1-locally)
44 | 2. [Hosted on IBM Cloud](#2.2-hosted-on-ibm-cloud)
45 | 3. [Create the service and deployment](#3-create-the-service-and-deployment)
46 | 4. [Access Drupal](#4-access-drupal)
47 |
48 | ### 1. Clone the repo
49 |
50 | Clone the `drupal-on-kubernetes-sample` locally. In a terminal, run:
51 |
52 | ```
53 | $ git clone https://github.com/IBM/drupal-on-kubernetes-sample
54 | ```
55 |
56 | ### 2. Create Kubernetes cluster
57 |
58 | Note: Minimum version 1.10 is required for both Kubernetes server and kubectl client.
59 |
60 | #### 2.1 Locally
61 |
62 | Follow the instructions for [running Kubernetes locally via Minikube](https://kubernetes.io/docs/setup/minikube/).
63 |
64 | #### 2.2 Hosted on IBM Cloud
65 | Follow the instructions for [creating a Kubernetes cluster in IBM Cloud](https://cloud.ibm.com/docs/containers/container_index.html#clusters).
66 |
67 | ### 3. Create the service and deployment
68 |
69 | Either run ['scripts/quickstart.sh'](scripts/quickstart.sh), or run the individual commands listed in it:
70 |
71 | ```shell
72 | kubectl create -f kubernetes/local-volumes.yaml
73 | kubectl create -f kubernetes/postgres.yaml
74 | kubectl create -f kubernetes/drupal.yaml
75 | ```
76 |
77 | ### 4. Access Drupal
78 |
79 | After deploying, we need to be sure that all pods are running. Check on the status via:
80 |
81 | ```shell
82 | kubectl get pods -l app=drupal
83 | ```
84 |
85 | Once all pod are running we need to know the IP adress of our Drupal.
86 |
87 | If you are running in Minikube, run the following:
88 |
89 | ```shell
90 | $ minikube service drupal --url
91 | ```
92 |
93 | If you are running in IBM Cloud, we will need to run the following:
94 |
95 | ```shell
96 | $ bx cs workers "$CLUSTER_NAME"
97 | OK
98 | ID Public IP Private IP Machine Type State Status
99 | kube-dal13-cr896f6348d71b4fd1ba151bc7c32abd46-w1 10.187.85.198 free normal Ready
100 | ```
101 |
102 | Access the newly deployed Drupal site via http://:30080
103 |
104 | ## Learn more
105 |
106 | * **Kubernetes on IBM Cloud**: Deliver your apps with the combined the power of [Kubernetes and Docker on IBM Cloud](https://www.ibm.com/cloud/container-service)
107 |
108 | ## License
109 | This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt).
110 |
111 | [Apache Software License (ASL) FAQ](https://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN)
112 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/.bluemix/toolchain.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------