Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Python Django Template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kubernetes Templates
Python Django Template
Commits
2c72bfb6
Commit
2c72bfb6
authored
6 years ago
by
Thomas MENARD
Browse files
Options
Downloads
Patches
Plain Diff
Add Dockerfile, gitlab-ci
parent
6589c1fd
No related branches found
No related tags found
1 merge request
!1
Update with a working example
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+16
-0
16 additions, 0 deletions
.gitlab-ci.yml
manifest.yaml
+190
-0
190 additions, 0 deletions
manifest.yaml
with
206 additions
and
0 deletions
.gitlab-ci.yml
+
16
−
0
View file @
2c72bfb6
...
@@ -18,3 +18,19 @@ build:
...
@@ -18,3 +18,19 @@ build:
-
docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME/polls:${CI_COMMIT_SHORT_SHA}"
-
docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME/polls:${CI_COMMIT_SHORT_SHA}"
tags
:
tags
:
-
k8s
-
k8s
deploy
:
stage
:
deploy
image
:
registry-gitlab.pasteur.fr/dsi-tools/docker-images:docker_kubernetes_image
variables
:
NAMESPACE
:
"
tmenard-django"
environment
:
name
:
tmenard-django
url
:
https://tmenard-django.k8s-dev.pasteur.fr
script
:
-
kubectl delete secret registry-gitlab -n ${NAMESPACE} --ignore-not-found=true
-
kubectl create secret docker-registry -n ${NAMESPACE} registry-gitlab --docker-server=registry-gitlab.pasteur.fr --docker-username=${DEPLOY_USER} --docker-password=${DEPLOY_TOKEN} --docker-email=kubernetes@pasteur.fr
-
envsubst < polls.yaml | kubectl apply -f -
-
kubectl patch deployment polls -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}"
tags
:
-
k8s
This diff is collapsed.
Click to expand it.
manifest.yaml
0 → 100644
+
190
−
0
View file @
2c72bfb6
---
apiVersion
:
v1
kind
:
PersistentVolumeClaim
metadata
:
name
:
postgres-claim
labels
:
app
:
postgresql
spec
:
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
1Gi
---
apiVersion
:
v1
kind
:
Secret
metadata
:
name
:
postgresql-credentials
type
:
Opaque
data
:
username
:
cG9sbHNfdXNlcgo=
password
:
cG9sbHMK
database
:
cG9sbHMK
---
apiVersion
:
extensions/v1beta1
kind
:
Deployment
metadata
:
name
:
postgresql
labels
:
app
:
postgresql
spec
:
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
app
:
postgresql
tier
:
postgreSQL
spec
:
containers
:
-
image
:
postgres:9.6.2-alpine
name
:
postgresql
env
:
-
name
:
POSTGRES_USER
valueFrom
:
secretKeyRef
:
name
:
postgresql-credentials
key
:
username
-
name
:
POSTGRES_DB
valueFrom
:
secretKeyRef
:
name
:
postgresql-credentials
key
:
database
-
name
:
POSTGRES_PASSWORD
valueFrom
:
secretKeyRef
:
name
:
postgresql-credentials
key
:
password
ports
:
-
containerPort
:
5432
name
:
postgresql
volumeMounts
:
-
name
:
postgresql
mountPath
:
/var/lib/postgresql/data
subPath
:
data
volumes
:
-
name
:
postgresql
persistentVolumeClaim
:
claimName
:
postgres-claim
-
name
:
postgresql-credentials
secret
:
secretName
:
postgresql
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
postgresql
labels
:
app
:
postgresql
spec
:
ports
:
-
port
:
5432
selector
:
app
:
postgresql
tier
:
postgreSQL
---
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_IMAGE/$CI_COMMIT_REF_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
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
polls
labels
:
app
:
polls
spec
:
type
:
ClusterIP
ports
:
-
port
:
80
targetPort
:
8080
selector
:
app
:
polls
---
apiVersion
:
extensions/v1beta1
kind
:
Ingress
metadata
:
annotations
:
kubernetes.io/ingress.class
:
traefik
labels
:
app
:
polls
name
:
polls
spec
:
rules
:
-
host
:
https://${CI_PROJECT_NAME}.k8s-dev.pasteur.fr
http
:
paths
:
-
backend
:
serviceName
:
polls
servicePort
:
80
path
:
/
---
apiVersion
:
batch/v1
kind
:
Job
metadata
:
name
:
polls-migrations
spec
:
template
:
spec
:
containers
:
-
name
:
django
image
:
$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment