Skip to content

Instantly share code, notes, and snippets.

@dimMaryanto93
Last active February 26, 2023 09:03
Show Gist options
  • Save dimMaryanto93/c8e8b75d52f1266a6bd7c8f5939c91f4 to your computer and use it in GitHub Desktop.
Save dimMaryanto93/c8e8b75d52f1266a6bd7c8f5939c91f4 to your computer and use it in GitHub Desktop.
Study Cases: Kubernetes pemula s/d Mahir
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config
data:
MYSQL_DATABASE: mahasiswa_db
---
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
stringData:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: default
MYSQL_PASSWORD: password
version: '3.9'
services:
laravel:
image: repository.dimas-maryanto.com:8087/dimmaryanto93/laravel-monolith-apps:v2
build:
dockerfile: Dockerfile
context: ./
ports:
- "8000:80"
environment:
APP_ENV: local
ARG PHP_VERSION=8.0-apache
ARG NODE_VERSION=14.15-alpine3.13
FROM php:${PHP_VERSION} as php_laravel
# install dependencies for laravel 8
RUN apt-get update && apt-get install -y \
curl \
git \
libicu-dev \
libpq-dev \
libmcrypt-dev \
mariadb-client \
openssl \
unzip \
vim \
zip \
zlib1g-dev \
libpng-dev \
libzip-dev && \
rm -r /var/lib/apt/lists/*
# install extension for laravel 8
RUN pecl install mcrypt-1.0.4 && \
docker-php-ext-install fileinfo exif pcntl bcmath gd mysqli pdo_mysql && \
docker-php-ext-enable mcrypt && \
a2enmod rewrite
# install composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV APP_SOURCE /var/www/php
# Set working directory
WORKDIR $APP_SOURCE
COPY .docker/000-default.apache.conf /etc/apache2/sites-enabled/000-default.conf
COPY .docker/apache2-foreground .docker/apache2-foreground
COPY .docker/migrate-db-entrypoint .docker/php-artisan-migrate
CMD [".docker/apache2-foreground"]
FROM node:$NODE_VERSION as laramix_build
WORKDIR /var/www/php
COPY . .
RUN npm install -q && \
npm run-script prod
FROM php_laravel as executeable
ENV APP_SOURCE /var/www/php
ENV APP_DEBUG=false
ENV APP_URL=""
ENV APP_ENV=production
ENV DB_CONNECTION=mysql
ENV DB_HOST=localhost
ENV DB_PORT=3306
ENV DB_DATABASE=laravel
ENV DB_USERNAME=laravel
ENV DB_PASSWORD=laravel
# copy source laravel
COPY . .
COPY --from=laramix_build /var/www/php/public/css public/css
COPY --from=laramix_build /var/www/php/public/fonts public/fonts
COPY --from=laramix_build /var/www/php/public/js public/js
# give full access
RUN mkdir -p public/storage && \
chmod -R 777 storage/* && \
chmod -R 777 public/storage && \
chmod -R 777 .docker/*
# install dependency laravel
RUN php -r "file_exists('.env') || copy('.env.example', '.env');" && \
composer install --no-interaction --optimize-autoloader --no-dev && \
php artisan package:discover --ansi && \
php artisan key:generate --ansi --force && \
php artisan optimize
VOLUME ${APP_SOURCE}/storage
# expose port default 80
EXPOSE 80/tcp
#!/bin/bash
set -e
php ${APP_SOURCE}/artisan config:clear
php ${APP_SOURCE}/artisan cache:clear
php ${APP_SOURCE}/artisan optimize
php ${APP_SOURCE}/artisan migrate --force -n
apiVersion: v1
kind: Pod
metadata:
name: laravel-apps
labels:
app: laravel
spec:
containers:
- name: laravel
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v1
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 500Mi
limits:
cpu: 1500m
memory: 1000Mi
ports:
- containerPort: 80
env:
- name: APP_URL
value: ""
- name: DB_HOST
value: mysql-db
- name: DB_PORT
value: "3306"
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql-config
- name: DB_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql-secret
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql-secret
restartPolicy: Always
apiVersion: v1
kind: Pod
metadata:
name: laravel-apps
labels:
app: laravel
spec:
initContainers:
- name: init-db
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v3
command: [".docker/migrate-db-entrypoint"]
env:
- name: DB_HOST
value: mysql-db
- name: DB_PORT
value: "3306"
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql-config
- name: DB_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql-secret
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql-secret
containers:
- name: laravel
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v3
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 500Mi
limits:
cpu: 1500m
memory: 1000Mi
livenessProbe:
httpGet:
port: http
path: /actuator/health/liveness
scheme: http
failureThreshold: 3
periodSeconds: 3
timeoutSeconds: 2
startupProbe:
httpGet:
port: http
path: /actuator/health/readiness
scheme: http
timeoutSeconds: 3
initialDelaySeconds: 3
ports:
- containerPort: 80
name: http
env:
- name: APP_URL
value: ""
- name: DB_HOST
value: mysql-db
- name: DB_PORT
value: "3306"
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql-config
- name: DB_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql-secret
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql-secret
restartPolicy: Always
apiVersion: v1
kind: Pod
metadata:
name: laravel-apps
labels:
app: laravel
spec:
initContainers:
- name: init-db
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v2
command: [".docker/migrate-db-entrypoint"]
env:
- name: DB_HOST
value: mysql-db
- name: DB_PORT
value: "3306"
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql-config
- name: DB_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql-secret
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql-secret
containers:
- name: laravel
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v2
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 500Mi
limits:
cpu: 1500m
memory: 1000Mi
ports:
- containerPort: 80
env:
- name: APP_URL
value: ""
- name: DB_HOST
value: mysql-db
- name: DB_PORT
value: "3306"
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql-config
- name: DB_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql-secret
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql-secret
restartPolicy: Always
apiVersion: v1
kind: Pod
metadata:
name: laravel-apps
labels:
app: laravel
spec:
containers:
- name: laravel
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
env:
- name: APP_URL
value: ""
restartPolicy: Always
apiVersion: v1
kind: Pod
metadata:
name: mysql-db
labels:
app: mysql
spec:
containers:
- name: mysql-db
image: mysql:8.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3306
envFrom:
- configMapRef:
name: mysql-config
optional: false
- secretRef:
name: mysql-secret
optional: false
restartPolicy: Always
apiVersion: v1
kind: Pod
metadata:
name: laravel-apps
labels:
app: laravel
spec:
containers:
- name: laravel
image: repository.dimas-maryanto.com:8086/dimmaryanto93/laravel-monolith-apps:v1
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 500Mi
limits:
cpu: 1500m
memory: 1000Mi
ports:
- containerPort: 80
env:
- name: APP_URL
value: ""
restartPolicy: Always
apiVersion: v1
kind: Service
metadata:
name: laravel-apps
spec:
selector:
app: laravel
ports:
- port: 8000
name: http
protocol: TCP
targetPort: 80
type: NodePort
apiVersion: v1
kind: Service
metadata:
name: mysql-db
spec:
selector:
app: mysql
ports:
- port: 3306
name: socket
targetPort: 3306
type: ClusterIP
Route::get('/actuator/health/liveness', function () {
try {
DB::connection()->getPdo();
return response('ok');
} catch (\Exception $e) {
return response("failed: \n". $e, 500);
}
});
Route::get('/actuator/health/readiness', function () {
return response('ok');
});
apiVersion: v1
kind: ConfigMap
metadata:
name: api-gateway
data:
template.conf: |
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /customer/ {
proxy_pass ${CUSTOMER_API_PROTO}://${CUSTOMER_API_HOST}:${CUSTOMER_API_PORT}${CUSTOMER_API_CONTEXT_PATH};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /order/ {
proxy_pass ${ORDERS_API_PROTO}://${ORDERS_API_HOST}:${ORDERS_API_PORT}${ORDERS_API_CONTEXT_PATH};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
---
apiVersion: v1
kind: Pod
metadata:
name: api-gateway
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: 192.168.88.50:8086/nginx:mainline
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
volumeMounts:
- mountPath: /etc/nginx/templates
name: default-template
env:
- name: CUSTOMER_API_PROTO
value: http
- name: CUSTOMER_API_HOST
value: "customer-api.customer-module"
- name: CUSTOMER_API_PORT
value: "9090"
- name: CUSTOMER_API_CONTEXT_PATH
value: "/"
- name: ORDERS_API_PROTO
value: "http"
- name: ORDERS_API_HOST
value: "orders-api.orders-module"
- name: ORDERS_API_PORT
value: "9091"
- name: ORDERS_API_CONTEXT_PATH
value: "/"
volumes:
- name: default-template
configMap:
name: api-gateway
items:
- key: template.conf
path: default.conf.template
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: api-gateway
spec:
selector:
app: api-gateway
ports:
- port: 80
name: http
targetPort: 80
nodePort: 30001
type: NodePort
apiVersion: v1
kind: ConfigMap
metadata:
name: orders-api
namespace: orders-module
data:
SERVICE_CUSTOMER_HOST: "customer-api.customer-module"
SERVICE_CUSTOMER_PORT: "9090"
SERVICE_CUSTOMER_PROTO: "http"
---
apiVersion: v1
kind: Pod
metadata:
name: orders-api
namespace: orders-module
labels:
app: orders-api
tier: backend
project: orders-api
spec:
containers:
- name: orders-api
image: 192.168.88.50:8086/dimmaryanto93/example/order-api:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9091
name: http
envFrom:
- configMapRef:
name: orders-api
optional: false
env:
- name: DATABASE_HOST
value: postgresql
- name: DATABASE_PORT
value: "5432"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
name: postgresql
key: POSTGRES_DB
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: POSTGRES_USER
name: postgresql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgresql
optional: false
restartPolicy: Always
version: '3.9'
volumes:
pg_data: { }
mysql_data: { }
services:
postgres:
image: 192.168.88.50:8086/postgres:15
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=order4p1
- POSTGRES_USER=order4p1
- POSTGRES_DB=order4p1
volumes:
- pg_data:/var/lib/postgresql/data
customerAPI:
image: 192.168.88.50:8087/dimmaryanto93/example/customer-api:latest
build:
dockerfile: Dockerfile
context: ./customer
args:
- JDK_VERSION=19-oraclelinux8
- JAR_FILE=customer-api.jar
environment:
- DATABASE_USER=customer4p1
- DATABASE_PASSWORD=customer4p1
- DATABASE_NAME=customer4p1
- DATABASE_HOST=mysql
- DATABASE_PORT=3306
ports:
- "9090:9090"
depends_on:
- mysql
mysql:
image: 192.168.88.50:8086/mysql:8.0
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=rootPasswordnyaApa
- MYSQL_DATABASE=customer4p1
- MYSQL_USER=customer4p1
- MYSQL_PASSWORD=customer4p1
volumes:
- mysql_data:/var/lib/mysql
orderAPI:
image: 192.168.88.50:8087/dimmaryanto93/example/order-api:latest
build:
dockerfile: Dockerfile
context: ./orders
args:
- JDK_VERSION=19-oraclelinux8
- JAR_FILE=orders-api.jar
ports:
- "9091:9091"
depends_on:
- postgres
environment:
- DATABASE_USER=order4p1
- DATABASE_PASSWORD=order4p1
- DATABASE_NAME=order4p1
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- SERVICE_CUSTOMER_HOST=customerAPI
- SERVICE_CUSTOMER_PORT=9090
- SERVICE_CUSTOMER_PROTO=http
version: '3.9'
volumes:
pg_data: {}
mysql_data: {}
services:
postgres:
image: 192.168.88.50:8086/postgres:15
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=order4p1
- POSTGRES_USER=order4p1
- POSTGRES_DB=order4p1
volumes:
- pg_data:/var/lib/postgresql/data
mysql:
image: 192.168.88.50:8086/mysql:8.0
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=rootPasswordnyaApa
- MYSQL_DATABASE=customer4p1
- MYSQL_USER=customer4p1
- MYSQL_PASSWORD=customer4p1
volumes:
- mysql_data:/var/lib/mysql
ARG JDK_VERSION=19-oraclelinux8
FROM openjdk:${JDK_VERSION}
LABEL maintainer="Dimas Maryanto <[email protected]>"
ARG JAR_FILE="customer-api.jar"
# copy file from local to images then rename to spring-boot.jar
ADD target/$JAR_FILE spring-boot.jar
ENV APPLICATION_PORT=9090
ENV PROFILE=default
ENV DATABASE_USER=postgres
ENV DATABASE_PASSWORD=postgres
ENV DATABASE_HOST=localhost
ENV DATABASE_NAME=postgres
ENV DATABASE_PORT=5432
ENV FLYWAY_ENABLED=true
# reqired command to run application
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "spring-boot.jar"]
ARG JDK_VERSION=19-oraclelinux8
FROM openjdk:${JDK_VERSION}
LABEL maintainer="Dimas Maryanto <[email protected]>"
ARG JAR_FILE="orders-api.jar"
# copy file from local to images then rename to spring-boot.jar
ADD target/$JAR_FILE spring-boot.jar
ENV APPLICATION_PORT=9091
ENV PROFILE=default
ENV DATABASE_USER=mysql
ENV DATABASE_PASSWORD=mysql_password
ENV DATABASE_HOST=localhost
ENV DATABASE_NAME=mysql_db
ENV DATABASE_PORT=3306
ENV FLYWAY_ENABLED=true
# reqired command to run application
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "spring-boot.jar"]
apiVersion: v1
kind: Namespace
metadata:
name: customer-module
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql
namespace: customer-module
data:
MYSQL_DATABASE: customer_api
---
apiVersion: v1
kind: Secret
metadata:
name: mysql
namespace: customer-module
stringData:
MYSQL_ROOT_PASSWORD: P4sSwordnyaRo0t
MYSQL_USER: customer_api
MYSQL_PASSWORD: customer_api
---
apiVersion: v1
kind: Pod
metadata:
name: mysql
namespace: customer-module
labels:
app: mysql
tier: database
project: customer
spec:
containers:
- name: mysql-server
image: 192.168.88.50:8086/mysql:8.0
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: mysql
optional: false
- secretRef:
name: mysql
optional: false
ports:
- containerPort: 3306
name: tcp
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: customer-module
spec:
selector:
app: mysql
tier: database
project: customer
ports:
- port: 3306
name: tcp
protocol: TCP
targetPort: 3306
type: NodePort
---
apiVersion: v1
kind: Pod
metadata:
name: customer-api
namespace: customer-module
labels:
app: customer-api
tier: backend
project: customer
spec:
containers:
- name: customer-api
image: 192.168.88.50:8086/dimmaryanto93/example/customer-api:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9090
name: http
env:
- name: DATABASE_HOST
value: mysql
- name: DATABASE_PORT
value: "3306"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: customer-api
namespace: customer-module
spec:
selector:
app: customer-api
tier: backend
project: customer
ports:
- port: 9090
name: http
type: NodePort
apiVersion: v1
kind: Namespace
metadata:
name: orders-module
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgresql
namespace: orders-module
data:
POSTGRES_DB: order_api
---
apiVersion: v1
kind: Secret
metadata:
name: postgresql
namespace: orders-module
stringData:
POSTGRES_PASSWORD: P4sSwordnyaPostg3s
POSTGRES_USER: orders_api
---
apiVersion: v1
kind: Pod
metadata:
name: postgresql
namespace: orders-module
labels:
app: postgresql
tier: database
project: orders-api
spec:
containers:
- name: postgresql
image: 192.168.88.50:8086/postgres:15.1
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: postgresql
optional: false
- secretRef:
name: postgresql
optional: false
ports:
- containerPort: 5432
name: tcp
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: postgresql
namespace: orders-module
spec:
selector:
app: postgresql
tier: database
project: orders-api
ports:
- port: 5432
name: tcp
type: NodePort
---
apiVersion: v1
kind: Pod
metadata:
name: orders-api
namespace: orders-module
labels:
app: orders-api
tier: backend
project: orders-api
spec:
containers:
- name: orders-api
image: 192.168.88.50:8086/dimmaryanto93/example/order-api:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9091
name: http
env:
- name: DATABASE_HOST
value: postgresql
- name: DATABASE_PORT
value: "5432"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
name: postgresql
key: POSTGRES_DB
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: POSTGRES_USER
name: postgresql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgresql
optional: false
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: orders-api
namespace: orders-module
spec:
selector:
app: orders-api
tier: backend
project: orders-api
ports:
- port: 9091
name: http
type: NodePort
apiVersion: v1
kind: Pod
metadata:
name: customer-api
namespace: customer-module
labels:
app: customer-api
tier: backend
project: customer
spec:
containers:
- name: customer-api
image: 192.168.88.50:8086/dimmaryanto93/example/customer-api:v2
imagePullPolicy: IfNotPresent
startupProbe:
httpGet:
port: http
path: /actuator/health/readiness
scheme: HTTP
failureThreshold: 3
timeoutSeconds: 3
initialDelaySeconds: 20
livenessProbe:
httpGet:
port: http
scheme: HTTP
path: /actuator/health/liveness
timeoutSeconds: 3
periodSeconds: 3
failureThreshold: 1
ports:
- containerPort: 9090
name: http
env:
- name: DATABASE_HOST
value: mysql
- name: DATABASE_PORT
value: "3306"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql
restartPolicy: Always
---
apiVersion: v1
kind: Pod
metadata:
name: orders-api
namespace: orders-module
labels:
app: orders-api
tier: backend
project: orders-api
spec:
containers:
- name: orders-api
image: 192.168.88.50:8086/dimmaryanto93/example/order-api:v2
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9091
name: http
startupProbe:
httpGet:
port: http
path: /actuator/health/readiness
scheme: HTTP
failureThreshold: 3
timeoutSeconds: 3
initialDelaySeconds: 20
livenessProbe:
httpGet:
port: http
scheme: HTTP
path: /actuator/health/liveness
timeoutSeconds: 3
periodSeconds: 3
failureThreshold: 1
envFrom:
- configMapRef:
name: orders-api
optional: false
env:
- name: DATABASE_HOST
value: postgresql
- name: DATABASE_PORT
value: "5432"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
name: postgresql
key: POSTGRES_DB
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: POSTGRES_USER
name: postgresql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgresql
optional: false
restartPolicy: Always
apiVersion: v1
kind: Pod
metadata:
name: customer-api
namespace: customer-module
labels:
app: customer-api
tier: backend
project: customer
spec:
containers:
- name: customer-api
image: 192.168.88.50:8086/dimmaryanto93/example/customer-api:v3
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 250Mi
limits:
cpu: 1500m
memory: 2000Mi
startupProbe:
httpGet:
port: http
path: /actuator/health/readiness
scheme: HTTP
failureThreshold: 3
timeoutSeconds: 3
initialDelaySeconds: 30
livenessProbe:
httpGet:
port: http
scheme: HTTP
path: /actuator/health/liveness
timeoutSeconds: 3
periodSeconds: 3
failureThreshold: 1
ports:
- containerPort: 9090
name: http
env:
- name: DATABASE_HOST
value: mysql
- name: DATABASE_PORT
value: "3306"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
key: MYSQL_DATABASE
name: mysql
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: MYSQL_USER
name: mysql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: mysql
restartPolicy: Always
---
apiVersion: v1
kind: Pod
metadata:
name: orders-api
namespace: orders-module
labels:
app: orders-api
tier: backend
project: orders-api
spec:
containers:
- name: orders-api
image: 192.168.88.50:8086/dimmaryanto93/example/order-api:v3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9091
name: http
resources:
requests:
cpu: 100m
memory: 250Mi
limits:
cpu: 1500m
memory: 2000Mi
startupProbe:
httpGet:
port: http
path: /actuator/health/readiness
scheme: HTTP
failureThreshold: 3
timeoutSeconds: 3
initialDelaySeconds: 30
livenessProbe:
httpGet:
port: http
scheme: HTTP
path: /actuator/health/liveness
timeoutSeconds: 3
periodSeconds: 3
failureThreshold: 1
envFrom:
- configMapRef:
name: orders-api
optional: false
env:
- name: DATABASE_HOST
value: postgresql
- name: DATABASE_PORT
value: "5432"
- name: DATABASE_NAME
valueFrom:
configMapKeyRef:
name: postgresql
key: POSTGRES_DB
optional: false
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
key: POSTGRES_USER
name: postgresql
optional: false
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgresql
optional: false
restartPolicy: Always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment