Skip to content
Snippets Groups Projects
Commit 5dd59fd3 authored by Thomas  MENARD's avatar Thomas MENARD
Browse files

Update README

parent 47b01704
No related branches found
No related tags found
No related merge requests found
......@@ -128,7 +128,7 @@ In order to deploy a Postgresql server we need :
- [ ] Deployment
- [ ] Service
* Persistent Volume Claim
##### Persistent Volume Claim
As a Docker image is immutable, you may need to define some persistent storage. In the case of a PostgreSQL container we need to persist the data of the database.
......@@ -150,7 +150,7 @@ resources:
storage: 1Gi
```
* PostgreSQL secret
##### PostgreSQL secret
We are here defining the PostgreSQL basic parameters : username, password and database. This `Secret` will be reused later in `Deployments`.
......@@ -170,7 +170,7 @@ password: c2xsb3BfYzNiaQo=
database: cG9sbHMK
```
* PostgreSQL Deployment
##### PostgreSQL Deployment
```yaml
apiVersion: extensions/v1beta1
......@@ -223,7 +223,7 @@ template:
secretName: postgresql
```
* PostgreSQL Service
##### PostgreSQL Service
```yaml
apiVersion: v1
......@@ -240,130 +240,130 @@ selector:
tier: postgreSQL
````
* Django Application
* Deployment
#### Django Application
##### Deployment
```yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: polls
labels:
app: polls
spec:
replicas: 3
template:
metadata:
labels:
app: polls
spec:
containers:
name: polls-app
image: ${CI_REGISTRY}/${CI_PROJECT_NAME}/polls:${CI_COMMIT_SHORT_SHA}
# This setting makes nodes pull the docker image every time before
# starting the pod. This is useful when debugging, but should be turned
# off in production.
imagePullPolicy: Always
env:
- name: DATABASE_NAME
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: database
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: password
ports:
- containerPort: 8080
volumes:
- name: postgresql-credentials
secret:
secretName: postgresql
```
* Service
```yaml
apiVersion: v1
kind: Service
```yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: polls
labels:
app: polls
spec:
replicas: 3
template:
metadata:
name: polls
labels:
app: polls
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
selector:
app: polls
```
containers:
name: polls-app
image: ${CI_REGISTRY}/${CI_PROJECT_NAME}/polls:${CI_COMMIT_SHORT_SHA}
# This setting makes nodes pull the docker image every time before
# starting the pod. This is useful when debugging, but should be turned
# off in production.
imagePullPolicy: Always
env:
- name: DATABASE_NAME
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: database
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: password
ports:
- containerPort: 8080
volumes:
- name: postgresql-credentials
secret:
secretName: postgresql
```
* Ingress Resource
##### Service
```yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: traefik
labels:
app: polls
name: polls
spec:
rules:
- host: ${CI_PROJECT_NAME}.pasteur.cloud
http:
paths:
- backend:
serviceName: polls
servicePort: 80
path: /
```
* Kubernetes Job
We will use a `Job` in order to manage django migrations.
> Note: Kubernetes jobs are run only once opposed to `Deployments` that run continiously.
```yaml
apiVersion: batch/v1
kind: Job
metadata:
name: polls-migrations
```yaml
apiVersion: v1
kind: Service
metadata:
name: polls
labels:
app: polls
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
selector:
app: polls
```
##### Ingress Resource
```yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: traefik
labels:
app: polls
name: polls
spec:
rules:
- host: ${CI_PROJECT_NAME}.pasteur.cloud
http:
paths:
- backend:
serviceName: polls
servicePort: 80
path: /
```
##### Kubernetes Job
We will use a `Job` in order to manage django migrations.
> Note: Kubernetes jobs are run only once opposed to `Deployments` that run continiously.
```yaml
apiVersion: batch/v1
kind: Job
metadata:
name: polls-migrations
spec:
template:
spec:
template:
spec:
containers:
- name: django
image: ${CI_REGISTRY}/${CI_PROJECT_NAME}/polls:${CI_COMMIT_SHORT_SHA}
command: ['python', 'manage.py', 'migrate']
env:
- name: DATABASE_NAME
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: database
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: password
restartPolicy: Never
backoffLimit: 5
```
containers:
- name: django
image: ${CI_REGISTRY}/${CI_PROJECT_NAME}/polls:${CI_COMMIT_SHORT_SHA}
command: ['python', 'manage.py', 'migrate']
env:
- name: DATABASE_NAME
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: database
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: password
restartPolicy: Never
backoffLimit: 5
```
### Setup Continuous Delivery in Gitlab CI
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment