Merge pull request #89 from surajssd/functional_tests

Functional Testing for kompose cmdline
This commit is contained in:
Suraj Deshmukh 2016-08-08 10:28:43 +05:30 committed by GitHub
commit aaa94d7103
35 changed files with 2918 additions and 0 deletions

12
script/test/README.md Normal file
View File

@ -0,0 +1,12 @@
# Functional Test
### Requirements
Install `jq - commandline JSON processor` with minimum version of 1.5
### Running tests
Test running ./cmd/tests.sh

View File

@ -0,0 +1,6 @@
#!/bin/bash
TEMP_DIR="/tmp/kompose/"
TEMP_STDOUT=$TEMP_DIR/test-stdout
TEMP_STDERR=$TEMP_DIR/test-stderr
EXIT_STATUS=0

154
script/test/cmd/lib.sh Normal file
View File

@ -0,0 +1,154 @@
#!/bin/bash
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/globals.sh
# setup all the things needed to run tests
function convert::init() {
mkdir -p $TEMP_DIR
SUCCESS_MSGS=""
FAIL_MSGS=""
}
readonly -f convert::init
# remove all the temporary files created for test
function convert::teardown() {
rm -rf $TEMP_DIR
SUCCESS_MSGS=""
FAIL_MSGS=""
}
readonly -f convert::teardown
# print about test start information
function convert::start_test() {
convert::init
echo -e "\n\n===> Starting test <==="
echo $@
}
readonly -f convert::start_test
# print in green about the test being passed
function convert::print_pass() {
tput setaf 2
tput bold
echo -en "PASS: $@"
tput sgr0
}
readonly -f convert::print_pass
# print in red about the test failed
function convert::print_fail() {
tput setaf 1
tput bold
echo -en "FAIL: $@"
tput sgr0
}
readonly -f convert::print_fail
# run a cmd, which saves stdout output to TEMP_STDOUT
# and saves errors to TEMP_STDERR files and returns exit status
function convert::run_cmd() {
cmd=$@
$cmd 2>$TEMP_STDERR >$TEMP_STDOUT
return $?
}
readonly -f convert::run_cmd
# run the command and match the output to the existing file
# if error then save error string in FAIL_MSGS
# if success save pass string in SUCCESS_MSGS
function convert::match_output() {
local cmd=$1
local expected_output=$2
convert::run_cmd $cmd
exit_status=$?
if [ $exit_status -ne 0 ]; then FAIL_MSGS=$FAIL_MSGS"exit status: $exit_status\n"; return $exit_status; fi
match=$(jq --argfile a $TEMP_STDOUT --argfile b $expected_output -n 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); ($a | (post_recurse | arrays) |= sort) as $a | ($b | (post_recurse | arrays) |= sort) as $b | $a == $b')
if ! [ $match ]; then FAIL_MSGS=$FAIL_MSGS"converted output does not match\n"; return 1;
else SUCCESS_MSGS=$SUCCESS_MSGS"converted output matches\n"; return 0; fi
}
readonly -f convert::match_output
# function called from outside which accecpts cmd to run and
# file to compare output with
function convert::expect_success() {
local cmd=$1
local expected_output=$2
convert::start_test "convert::expect_success: Running: '${cmd}' expected_output: '${expected_output}'"
convert::match_output "$cmd" "$expected_output"
if [ $? -ne 0 ]; then convert::print_fail $FAIL_MSGS; convert::teardown; EXIT_STATUS=1; return 1;
else convert::print_pass $SUCCESS_MSGS; fi
# check if no warnings are generated? If yes then fail
warnings=$(stat -c%s $TEMP_STDERR)
if [ $warnings -ne 0 ]; then convert::print_fail "warnings given: $(cat $TEMP_STDERR)"; EXIT_STATUS=1; fi
convert::teardown
}
readonly -f convert::expect_success
# function called from outside, which accepts cmd to run,
# expected output file and warnings if any
function convert::expect_success_and_warning() {
local cmd=$1
local expected_output=$2
local expected_warning=$3
convert::start_test "convert::expect_success_and_warning: Running: '${cmd}' expected_output: '${expected_output}' expected_warning: '${expected_warning}'"
convert::match_output "$cmd" "$expected_output"
if [ $? -ne 0 ]; then convert::print_fail $FAIL_MSGS; convert::teardown; EXIT_STATUS=1; return 1;
else convert::print_pass $SUCCESS_MSGS; fi
grep -i "$expected_warning" $TEMP_STDERR > /dev/null
local exit_status=$?
if [ $exit_status -ne 0 ]; then convert::print_fail "no warning found: '$expected_warning'"; EXIT_STATUS=1;
else convert::print_pass "warning found: '$expected_warning'"; fi
convert::teardown
return $exit_status
}
readonly -f convert::expect_success_and_warning
# function called from outside, which accepts cmd to run,
# expects warning, without caring if the cmd ran passed or failed
function convert::expect_warning() {
local cmd=$1
local expected_warning=$2
convert::start_test "convert::expect_warning: Running: '${cmd}' expected_warning: '${expected_warning}'"
$cmd 2>$TEMP_STDERR >$TEMP_STDOUT
grep -i "$expected_warning" $TEMP_STDERR > /dev/null
local exit_status=$?
if [ $exit_status -ne 0 ]; then convert::print_fail "no warning found: '$expected_warning'"; EXIT_STATUS=1;
else convert::print_pass "warning found: '$expected_warning'"; fi
convert::teardown
return $exit_status
}
readonly -f convert::expect_warning
# function called from outside, which accepts cmd to run,
# expects failure, if the command passes then errors out.
function convert::expect_failure() {
local cmd=$1
convert::start_test "convert::expect_failure: Running: '${cmd}'"
convert::run_cmd $cmd
exit_status=$?
if [ $exit_status -eq 0 ]; then convert::print_fail "no error output, returned exit status 0"; EXIT_STATUS=1;
else convert::print_pass "errored out with exit status: $exit_status"; fi
convert::teardown
return $exit_status
}
readonly -f convert::expect_failure

55
script/test/cmd/tests.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
#######
# Tests related to docker-compose file in /script/test/fixtures/etherpad
convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml"
convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-image.yml"
convert::expect_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-ports.yml" "Service cannot be created because of missing port."
export $(cat $KOMPOSE_ROOT/script/test/fixtures/etherpad/envs)
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/etherpad/output-k8s.json" "Unsupported key depends_on - ignoring"
# openshift test
convert::expect_success_and_warning "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/etherpad/output-os.json" "Unsupported key depends_on - ignoring"
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/etherpad/envs | cut -d'=' -f1)
######
# Tests related to docker-compose file in script/test/fixtures/flask-redis
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/flask-redis/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/flask-redis/output-k8s.json" "Unsupported key depends_on - ignoring"
# openshift test
convert::expect_success_and_warning "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/flask-redis/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/flask-redis/output-os.json" "Unsupported key depends_on - ignoring"
######
# Tests related to docker-compose file in /script/test/fixtures/gitlab
convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml"
export $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs)
# kubernetes test
convert::expect_success "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/gitlab/output-k8s.json"
# openshift test
convert::expect_success "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/gitlab/output-os.json"
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs | cut -d'=' -f1)
######
# Tests related to docker-compose file in /script/test/fixtures/ngnix-node-redis
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-k8s.json" "Unsupported key build - ignoring"
# openshift test
convert::expect_success_and_warning "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-os.json" "Unsupported key build - ignoring"
######
# Tests related to docker-compose file in /script/test/fixtures/wordpress
convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/wordpress/docker-compose.yml"
export $(cat $KOMPOSE_ROOT/script/test/fixtures/wordpress/envs)
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/wordpress/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/wordpress/output-k8s.json" "Unsupported key depends_on - ignoring"
# openshift test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/wordpress/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/wordpress/output-os.json" "Unsupported key depends_on - ignoring"
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/wordpress/envs | cut -d'=' -f1)
exit $EXIT_STATUS

14
script/test/fixtures/etherpad/README.md vendored Normal file
View File

@ -0,0 +1,14 @@
## Docker Compose Etherpad
Etherpad and Mariadb
### Usage
The simplest thing to do:
```bash
export $(cat envs)
docker-compose up
```
To customize the values edit `envs` file.

View File

@ -0,0 +1,11 @@
version: "2"
services:
mariadb:
ports:
- 3306
etherpad:
ports:
- "80:9001"

View File

@ -0,0 +1,5 @@
version: "2"
services:
mariadb:
image: centos/mariadb

View File

@ -0,0 +1,25 @@
version: "2"
services:
mariadb:
image: centos/mariadb
ports:
- "$DB_PORT"
environment:
MYSQL_ROOT_PASSWORD: $ROOT_PASS
MYSQL_DATABASE: $DB_NAME
MYSQL_PASSWORD: $DB_PASS
MYSQL_USER: $DB_USER
etherpad:
image: centos/etherpad
ports:
- "80:9001"
depends_on:
- mariadb
environment:
DB_HOST: $DB_HOST
DB_DBID: $DB_NAME
DB_PASS: $DB_PASS
DB_PORT: $DB_PORT
DB_USER: $DB_USER

6
script/test/fixtures/etherpad/envs vendored Normal file
View File

@ -0,0 +1,6 @@
DB_HOST=mariadb
ROOT_PASS=etherpad
DB_NAME=etherpad
DB_PASS=etherpad
DB_USER=etherpad
DB_PORT=3306

View File

@ -0,0 +1,184 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 9001
}
],
"selector": {
"service": "etherpad"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "etherpad"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"containers": [
{
"name": "etherpad",
"image": "centos/etherpad",
"ports": [
{
"containerPort": 9001,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_HOST",
"value": "mariadb"
},
{
"name": "DB_PASS",
"value": "etherpad"
},
{
"name": "DB_PORT",
"value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
},
{
"name": "DB_DBID",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "mariadb"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_USER",
"value": "etherpad"
},
{
"name": "MYSQL_DATABASE",
"value": "etherpad"
},
{
"name": "MYSQL_PASSWORD",
"value": "etherpad"
},
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}

View File

@ -0,0 +1,188 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 9001
}
],
"selector": {
"service": "etherpad"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "etherpad"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"containers": [
{
"name": "etherpad",
"image": "centos/etherpad",
"ports": [
{
"containerPort": 9001,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_PORT",
"value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
},
{
"name": "DB_DBID",
"value": "etherpad"
},
{
"name": "DB_HOST",
"value": "mariadb"
},
{
"name": "DB_PASS",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "mariadb"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "etherpad"
},
{
"name": "MYSQL_USER",
"value": "etherpad"
},
{
"name": "MYSQL_DATABASE",
"value": "etherpad"
},
{
"name": "MYSQL_PASSWORD",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}

View File

@ -0,0 +1,10 @@
## Flask and Redis
For running this app
```bash
mkdir /opt/redis
sudo chcon -Rt svirt_sandbox_file_t /opt/redis
docker-compose up
```

View File

@ -0,0 +1,20 @@
version: "2"
services:
redis:
image: dharmit/redis
command: redis-server
ports:
- "6379"
volumes:
- /opt/redis:/redis
flask:
image: dharmit/flask
ports:
- "31000:5000"
depends_on:
- redis
environment:
REDIS_PORT: 6379
REDIS_HOST: redis

View File

@ -0,0 +1,168 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"ports": [
{
"name": "31000",
"protocol": "TCP",
"port": 31000,
"targetPort": 5000
}
],
"selector": {
"service": "flask"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "redis"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"volumes": [
{
"name": "fpllngzieyoh43e0133o",
"hostPath": {
"path": "/opt/redis"
}
}
],
"containers": [
{
"name": "redis",
"image": "dharmit/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {},
"volumeMounts": [
{
"name": "fpllngzieyoh43e0133o",
"mountPath": "/redis"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "flask"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"containers": [
{
"name": "flask",
"image": "dharmit/flask",
"ports": [
{
"containerPort": 5000,
"protocol": "TCP"
}
],
"env": [
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}

View File

@ -0,0 +1,172 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"ports": [
{
"name": "31000",
"protocol": "TCP",
"port": 31000,
"targetPort": 5000
}
],
"selector": {
"service": "flask"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"volumes": [
{
"name": "fpllngzieyoh43e0133o",
"hostPath": {
"path": "/opt/redis"
}
}
],
"containers": [
{
"name": "redis",
"image": "dharmit/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {},
"volumeMounts": [
{
"name": "fpllngzieyoh43e0133o",
"mountPath": "/redis"
}
]
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "flask"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"containers": [
{
"name": "flask",
"image": "dharmit/flask",
"ports": [
{
"containerPort": 5000,
"protocol": "TCP"
}
],
"env": [
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}

14
script/test/fixtures/gitlab/README.md vendored Normal file
View File

@ -0,0 +1,14 @@
## Gitlab
Gitlab, Postgresql, Redis
### Usage
The simplest thing to do:
```bash
export $(cat envs)
docker-compose up
```
To customize the values edit `envs` file.

View File

@ -0,0 +1,33 @@
version: "2"
services:
postgresql:
image: swordphilic/postgresql
ports:
- "$DB_PORT"
environment:
DB_NAME: $DB_NAME
DB_PASS: $DB_PASS
DB_USER: $DB_USER
gitlab:
image: swordphilic/gitlab
ports:
- "30000:80"
- "30001:443"
- "30002:22"
restart: always
environment:
DB_TYPE: postgres
DB_HOST: postgresql
DB_PORT: $DB_PORT
DB_NAME: $DB_NAME
DB_PASS: $DB_PASS
DB_USER: $DB_USER
REDIS_HOST: redis
REDIS_PORT: $REDIS_PORT
redis:
image: swordphilic/redis
ports:
- "$REDIS_PORT"

5
script/test/fixtures/gitlab/envs vendored Normal file
View File

@ -0,0 +1,5 @@
DB_PORT=5432
DB_NAME=gitlab
DB_PASS=gitlab
DB_USER=gitlab
REDIS_PORT=6379

View File

@ -0,0 +1,284 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"ports": [
{
"name": "30000",
"protocol": "TCP",
"port": 30000,
"targetPort": 80
},
{
"name": "30001",
"protocol": "TCP",
"port": 30001,
"targetPort": 443
},
{
"name": "30002",
"protocol": "TCP",
"port": 30002,
"targetPort": 22
}
],
"selector": {
"service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"protocol": "TCP",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "redis"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "swordphilic/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "gitlab"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": "swordphilic/gitlab",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
},
{
"containerPort": 443,
"protocol": "TCP"
},
{
"containerPort": 22,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
},
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "postgresql"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"containers": [
{
"name": "postgresql",
"image": "swordphilic/postgresql",
"ports": [
{
"containerPort": 5432,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_USER",
"value": "gitlab"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}

View File

@ -0,0 +1,290 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"protocol": "TCP",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"ports": [
{
"name": "30000",
"protocol": "TCP",
"port": 30000,
"targetPort": 80
},
{
"name": "30001",
"protocol": "TCP",
"port": 30001,
"targetPort": 443
},
{
"name": "30002",
"protocol": "TCP",
"port": 30002,
"targetPort": 22
}
],
"selector": {
"service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "postgresql"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"containers": [
{
"name": "postgresql",
"image": "swordphilic/postgresql",
"ports": [
{
"containerPort": 5432,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_USER",
"value": "gitlab"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "swordphilic/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "gitlab"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": "swordphilic/gitlab",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
},
{
"containerPort": 443,
"protocol": "TCP"
},
{
"containerPort": 22,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
},
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}

View File

@ -0,0 +1,7 @@
### Usage
Ref: http://anandmanisankar.com/posts/docker-container-nginx-node-redis-example/
```bash
docker-compose up
```

View File

@ -0,0 +1,25 @@
version: "2"
services:
nginx:
build: ./nginx
ports:
- "80:80"
restart: always
node1:
build: ./node
ports:
- "8080"
node2:
build: ./node
ports:
- "8080"
node3:
build: ./node
ports:
- "8080"
redis:
image: redis
ports:
- "6379"

View File

@ -0,0 +1,8 @@
# Set nginx base image
FROM nginx
# File Author / Maintainer
MAINTAINER Anand Mani Sankar
# Copy custom configuration file from the current directory
COPY nginx.conf /etc/nginx/nginx.conf

View File

@ -0,0 +1,26 @@
worker_processes 4;
events { worker_connections 1024; }
http {
upstream node-app {
least_conn;
server node1:8080 weight=60 max_fails=10 fail_timeout=60s;
server node2:8080 weight=60 max_fails=10 fail_timeout=60s;
server node3:8080 weight=60 max_fails=10 fail_timeout=60s;
}
server {
listen 80;
location / {
proxy_pass http://node-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}

View File

@ -0,0 +1,16 @@
FROM centos:7
RUN yum -y install epel-release && yum install -y nodejs npm gcc* make
RUN /bin/bash -c 'npm install -g nodemon' && mkdir /src
# Define working directory
WORKDIR /src
ADD . /src
RUN cd /src && npm install
# Expose port
EXPOSE 8080
# Run app using nodemon
CMD /bin/bash -c 'nodemon /src/index.js'

View File

@ -0,0 +1,28 @@
var express = require('express'),
http = require('http'),
redis = require('redis');
var app = express();
console.log(process.env.REDIS_PORT_6379_TCP_ADDR + ':' + process.env.REDIS_PORT_6379_TCP_PORT);
// APPROACH 1: Using environment variables created by Docker
// var client = redis.createClient(
// process.env.REDIS_PORT_6379_TCP_PORT,
// process.env.REDIS_PORT_6379_TCP_ADDR
// );
// APPROACH 2: Using host entries created by Docker in /etc/hosts (RECOMMENDED)
var client = redis.createClient('6379', 'redis');
app.get('/', function(req, res, next) {
client.incr('counter', function(err, counter) {
if(err) return next(err);
res.send('This page has been viewed ' + counter + ' times!');
});
});
http.createServer(app).listen(process.env.PORT || 8080, function() {
console.log('Listening on port ' + (process.env.PORT || 8080));
});

View File

@ -0,0 +1,14 @@
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "Anand Mani Sankar",
"license": "ISC",
"dependencies": {
"express": "^4.12.3",
"hiredis": "^0.2.0",
"mocha": "^2.2.1",
"redis": "^0.12.1"
}
}

View File

@ -0,0 +1,7 @@
var assert = require("assert");
describe('Dummy Test', function(){
it('should pass', function(){
assert.ok(true, "It is true!");
});
});

View File

@ -0,0 +1,356 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 80
}
],
"selector": {
"service": "nginx"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node1"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node2"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node3"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "nginx"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"containers": [
{
"name": "nginx",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "node1"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"containers": [
{
"name": "node1",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "node2"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"containers": [
{
"name": "node2",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "node3"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "redis"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}

View File

@ -0,0 +1,366 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node3"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 80
}
],
"selector": {
"service": "nginx"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node1"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node2"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "nginx"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"containers": [
{
"name": "nginx",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "node1"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"containers": [
{
"name": "node1",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "node2"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"containers": [
{
"name": "node2",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "node3"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}

View File

@ -0,0 +1,14 @@
## Docker Compose Wordpress
Wordpress and Mariadb
### Usage
The simplest thing to do:
```bash
export $(cat envs)
docker-compose up
```
To customize the values edit `envs` file.

View File

@ -0,0 +1,25 @@
version: "2"
services:
mariadb:
image: centos/mariadb
ports:
- "$DB_PORT"
environment:
MYSQL_ROOT_PASSWORD: $ROOT_PASS
MYSQL_DATABASE: $DB_NAME
MYSQL_PASSWORD: $DB_PASS
MYSQL_USER: $DB_USER
wordpress:
image: wordpress
ports:
- "8080:80"
depends_on:
- mariadb
restart: always
environment:
WORDPRESS_DB_HOST: $DB_HOST:$DB_PORT
WORDPRESS_DB_NAME: $DB_NAME
WORDPRESS_DB_PASSWORD: $DB_PASS
WORDPRESS_DB_USER: $DB_USER

6
script/test/fixtures/wordpress/envs vendored Normal file
View File

@ -0,0 +1,6 @@
DB_HOST=mariadb
ROOT_PASS=wordpress
DB_NAME=wordpress
DB_PASS=wordpress
DB_USER=wordpress
DB_PORT=3306

View File

@ -0,0 +1,180 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 80
}
],
"selector": {
"service": "wordpress"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "mariadb"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_PASSWORD",
"value": "wordpress"
},
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "wordpress"
},
{
"name": "MYSQL_USER",
"value": "wordpress"
},
{
"name": "MYSQL_DATABASE",
"value": "wordpress"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "wordpress"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"containers": [
{
"name": "wordpress",
"image": "wordpress",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"env": [
{
"name": "WORDPRESS_DB_HOST",
"value": "mariadb:3306"
},
{
"name": "WORDPRESS_DB_NAME",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_PASSWORD",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_USER",
"value": "wordpress"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}

View File

@ -0,0 +1,184 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 80
}
],
"selector": {
"service": "wordpress"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "wordpress"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"containers": [
{
"name": "wordpress",
"image": "wordpress",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"env": [
{
"name": "WORDPRESS_DB_NAME",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_PASSWORD",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_USER",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_HOST",
"value": "mariadb:3306"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "mariadb"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "wordpress"
},
{
"name": "MYSQL_USER",
"value": "wordpress"
},
{
"name": "MYSQL_DATABASE",
"value": "wordpress"
},
{
"name": "MYSQL_PASSWORD",
"value": "wordpress"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}