-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
384 additions
and
10 deletions.
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
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,89 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ms-kafka | ||
labels: | ||
app: ms-kafka | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ms-kafka | ||
template: | ||
metadata: | ||
labels: | ||
app: ms-kafka | ||
spec: | ||
containers: | ||
- name: ms-kafka | ||
image: wurstmeister/kafka | ||
ports: | ||
- containerPort: 9092 | ||
env: | ||
- name: KAFKA_ADVERTISED_HOST_NAME | ||
value: 127.0.0.1 | ||
- name: KAFKA_ZOOKEEPER_CONNECT | ||
value: ms-zookeeper-service:2181 | ||
- name: KAFKA_AUTO_CREATE_TOPICS_ENABLE | ||
value: 'true' | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ms-kafka-service | ||
labels: | ||
app: ms-kafka | ||
spec: | ||
selector: | ||
app: ms-kafka | ||
ports: | ||
- protocol: TCP | ||
port: 9092 | ||
targetPort: 9092 | ||
type: LoadBalancer | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ms-zookeeper | ||
labels: | ||
app: ms-zookeeper | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ms-zookeeper | ||
template: | ||
metadata: | ||
labels: | ||
app: ms-zookeeper | ||
spec: | ||
containers: | ||
- name: ms-zookeeper | ||
image: wurstmeister/zookeeper | ||
ports: | ||
- containerPort: 2181 | ||
env: | ||
- name: ZOOKEEPER_CLIENT_PORT | ||
value: "2181" | ||
- name: ZOOKEEPER_TICK_TIME | ||
value: "2000" | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ms-zookeeper-service | ||
labels: | ||
app: ms-zookeeper | ||
spec: | ||
selector: | ||
app: ms-zookeeper | ||
ports: | ||
- protocol: TCP | ||
port: 2181 | ||
targetPort: 2181 | ||
type: LoadBalancer | ||
|
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,79 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ms-keycloak | ||
labels: | ||
app: ms-keycloak | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ms-keycloak | ||
template: | ||
metadata: | ||
name: ms-keycloak-pod | ||
labels: | ||
app: ms-keycloak | ||
spec: | ||
containers: | ||
- name: ms-keycloak-container | ||
image: quay.io/keycloak/keycloak:22.0.3 | ||
command: [ "/opt/keycloak/bin/kc.sh", "start-dev", "--db postgres" ] | ||
env: | ||
- name: KC_DB_URL | ||
value: jdbc:postgresql://ms-postgres-service:5432/keycloak | ||
- name: KC_DB_PASSWORD | ||
value: postgres | ||
- name: KC_DB_USERNAME | ||
value: postgres | ||
- name: KEYCLOAK_ADMIN | ||
value: admin | ||
- name: KEYCLOAK_ADMIN_PASSWORD | ||
value: admin | ||
- name: HOSTNAME | ||
value: localhost | ||
ports: | ||
- containerPort: 8080 | ||
- containerPort: 8787 | ||
volumeMounts: | ||
- name: ms-keycloak-storage | ||
mountPath: /var/lib/keycloak/data | ||
volumes: | ||
- name: ms-keycloak-storage | ||
persistentVolumeClaim: | ||
claimName: ms-keycloak-pvc | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ms-keycloak-service | ||
labels: | ||
app: ms-keycloak | ||
spec: | ||
selector: | ||
app: ms-keycloak | ||
type: LoadBalancer | ||
ports: | ||
- name: http | ||
protocol: TCP | ||
port: 8082 | ||
targetPort: 8080 | ||
- name: debug | ||
protocol: TCP | ||
port: 8787 | ||
targetPort: 8787 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: ms-keycloak-pvc | ||
labels: | ||
app: ms-keycloak | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 200Mi |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -u | ||
|
||
function create_user_and_database() { | ||
local database=$1 | ||
echo " Creating user and database '$database'" | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE USER $database; | ||
CREATE DATABASE $database; | ||
GRANT ALL PRIVILEGES ON DATABASE $database TO $database; | ||
EOSQL | ||
} | ||
|
||
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then | ||
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" | ||
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do | ||
create_user_and_database $db | ||
done | ||
echo "Multiple databases created" | ||
fi |
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,119 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ms-postgres | ||
labels: | ||
app: ms-postgres | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ms-postgres | ||
template: | ||
metadata: | ||
name: ms-postgres-pod | ||
labels: | ||
app: ms-postgres | ||
spec: | ||
containers: | ||
- name: ms-postgres-container | ||
image: postgres:15.1-alpine | ||
ports: | ||
- containerPort: 5432 | ||
env: | ||
- name: POSTGRES_USER | ||
value: postgres | ||
- name: POSTGRES_PASSWORD | ||
value: postgres | ||
- name: POSTGRES_MULTIPLE_DATABASES | ||
value: stock,cms,keycloak | ||
volumeMounts: | ||
- name: ms-postgres-storage | ||
mountPath: /var/lib/postgresql/data | ||
- name: ms-postgres-init | ||
mountPath: /docker-entrypoint-initdb.d/init.sh | ||
subPath: init_db_schema.sh | ||
volumes: | ||
- name: ms-postgres-init | ||
configMap: | ||
name: ms-postgres-init-db-script | ||
- name: ms-postgres-storage | ||
persistentVolumeClaim: | ||
claimName: ms-postgres-pvc | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ms-postgres-service | ||
labels: | ||
app: ms-postgres | ||
spec: | ||
selector: | ||
app: ms-postgres | ||
ports: | ||
- protocol: TCP | ||
port: 5432 | ||
targetPort: 5432 | ||
type: NodePort | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: ms-postgres-storage | ||
labels: | ||
app: ms-postgres | ||
spec: | ||
capacity: | ||
storage: 500Mi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: /var/lib/docker/volumes/microservice-search/postgres | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: ms-postgres-pvc | ||
labels: | ||
app: ms-postgres | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 500Mi | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ms-postgres-init-db-script | ||
data: | ||
init_db_schema.sh: | | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
function create_user_and_database() { | ||
local database=$1 | ||
echo " Creating user and database '$database'" | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE USER $database; | ||
CREATE DATABASE $database; | ||
GRANT ALL PRIVILEGES ON DATABASE $database TO $database; | ||
EOSQL | ||
} | ||
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then | ||
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" | ||
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do | ||
create_user_and_database $db | ||
done | ||
echo "Multiple databases created" | ||
fi | ||
Oops, something went wrong.