-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from chibiegg/feat/k8s
kubernatesに変更
- Loading branch information
Showing
13 changed files
with
350 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,8 @@ README.md | |
.gitignore | ||
.git/ | ||
media/icons/* | ||
docs/ | ||
kubernates/ | ||
nginx/ | ||
logs/ | ||
data/ |
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 |
---|---|---|
|
@@ -103,4 +103,5 @@ venv.bak/ | |
# mypy | ||
.mypy_cache/ | ||
|
||
log/ | ||
logs/ | ||
data/ |
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,25 @@ | ||
all: nginx app | ||
|
||
.PHONY: nginx app apply delete | ||
|
||
nginx: nginx/Dockerfile | ||
cd nginx && docker build -t isucon/portal-nginx . | ||
|
||
app: Dockerfile | ||
docker build -t isucon/portal-app . | ||
|
||
apply: | ||
kubectl apply -f kubernates/00-*.yml | ||
kubectl apply -f kubernates/01-*.yml | ||
kubectl apply -f kubernates/02-*.yml | ||
kubectl apply -f kubernates/03-*.yml | ||
kubectl apply -f kubernates/04-*.yml | ||
kubectl apply -f kubernates/05-*.yml | ||
|
||
delete: | ||
kubectl delete -f kubernates/05-*.yml | ||
kubectl delete -f kubernates/04-*.yml | ||
kubectl delete -f kubernates/03-*.yml | ||
kubectl delete -f kubernates/02-*.yml | ||
kubectl delete -f kubernates/01-*.yml | ||
kubectl delete -f kubernates/00-*.yml |
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
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,18 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: portal-secret | ||
type: Opaque | ||
data: | ||
github_key: NjUwYjFjODVkMTVjOWJlMzgzNmU= | ||
# 650b1c85d15c9be3836e | ||
github_secret: YmY4OWE0MTBmNDk5YzY3NGI0ZTllOTljZjE0Nzg2ZWU3MDhjM2YzZQ== | ||
# bf89a410f499c674b4e9e99cf14786ee708c3f3e | ||
django_allowed_host: cG9ydGFsLmlzdWNvbi5uZXQ= | ||
# portal.isucon.net | ||
slack_endpoint_url: aHR0cHM6Ly9ob29rcy5zbGFjay5jb20vc2VydmljZXMvVDA1MDZWOEpLL0JMOEE1MFJBNy96M0xXR0t0TVdFMHVONlluYm5CaTFGbHA= | ||
# https://hooks.slack.com/services/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 | ||
alibaba_access_key_id: TFRBSXpjVGptU3h3bzhwSg== | ||
# LTAIzcTjmSxwo8pJ | ||
alibaba_access_key_secret: ZFE4dmkwYnBpNzE0aFlLblZmQ2YySzNwb2h2Sjhn | ||
# dQ8vi0bpi714hYKnVfCf2K3pohvJ8g |
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,33 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: portal-redis | ||
spec: | ||
ports: | ||
- port: 6379 | ||
selector: | ||
app: portal-redis | ||
|
||
--- | ||
|
||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: portal-redis | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: portal-redis | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: portal-redis | ||
spec: | ||
containers: | ||
- image: redis:5.0-alpine | ||
name: portal-redis | ||
ports: | ||
- containerPort: 6379 | ||
name: portal-redis |
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,47 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: portal-db | ||
spec: | ||
ports: | ||
- port: 5432 | ||
selector: | ||
app: portal-db | ||
|
||
--- | ||
|
||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: portal-db | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: portal-db | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: portal-db | ||
spec: | ||
containers: | ||
- image: postgres:12-alpine | ||
name: portal-db | ||
env: | ||
- name: POSTGRES_DB | ||
value: isucon | ||
- name: POSTGRES_USER | ||
value: isucon | ||
- name: POSTGRES_PASSWORD | ||
value: password | ||
ports: | ||
- containerPort: 5432 | ||
name: portal-db | ||
volumeMounts: | ||
- name: postgress-volume | ||
mountPath: /var/lib/postgresql/data | ||
volumes: | ||
- name: postgress-volume | ||
hostPath: | ||
path: /opt/portal/data/postgresql |
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,57 @@ | ||
kind: PersistentVolume | ||
apiVersion: v1 | ||
metadata: | ||
name: portal-static-volume | ||
spec: | ||
storageClassName: manual | ||
capacity: | ||
storage: 100Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: /opt/portal/data/static | ||
|
||
--- | ||
|
||
kind: PersistentVolume | ||
apiVersion: v1 | ||
metadata: | ||
name: portal-static-nginx-volume | ||
spec: | ||
storageClassName: manual | ||
capacity: | ||
storage: 100Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: /opt/portal/data/static | ||
|
||
--- | ||
|
||
kind: PersistentVolume | ||
apiVersion: v1 | ||
metadata: | ||
name: portal-media-volume | ||
spec: | ||
storageClassName: manual | ||
capacity: | ||
storage: 100Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: /opt/portal/data/media | ||
|
||
--- | ||
|
||
kind: PersistentVolume | ||
apiVersion: v1 | ||
metadata: | ||
name: portal-media-nginx-volume | ||
spec: | ||
storageClassName: manual | ||
capacity: | ||
storage: 100Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: /opt/portal/data/media |
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,93 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: portal-app | ||
spec: | ||
ports: | ||
- port: 5000 | ||
selector: | ||
app: portal-app | ||
|
||
--- | ||
|
||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: portal-app | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: portal-app | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: portal-app | ||
spec: | ||
containers: | ||
- image: isucon/portal-app:latest | ||
imagePullPolicy: IfNotPresent | ||
name: portal-app | ||
env: | ||
- name: REDIS_HOST | ||
value: portal-redis | ||
- name: DJANGO_DATABASE_TYPE | ||
value: postgres | ||
- name: POSTGRES_HOST | ||
value: portal-db | ||
- name: DJANGO_DEBUG | ||
value: "false" | ||
- name: CONTEST | ||
value: "false" | ||
- name: GITHUB_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: portal-secret | ||
key: github_key | ||
- name: GITHUB_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: portal-secret | ||
key: github_secret | ||
- name: DJANGO_ALLOWED_HOST | ||
valueFrom: | ||
secretKeyRef: | ||
name: portal-secret | ||
key: django_allowed_host | ||
- name: SLACK_ENDPOINT_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: portal-secret | ||
key: slack_endpoint_url | ||
- name: ALIBABA_ACCESS_KEY_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: portal-secret | ||
key: alibaba_access_key_id | ||
- name: ALIBABA_ACCESS_KEY_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: portal-secret | ||
key: alibaba_access_key_secret | ||
ports: | ||
- containerPort: 5000 | ||
name: portal-app | ||
volumeMounts: | ||
- name: static-volume | ||
mountPath: /opt/app/static | ||
- name: media-volume | ||
mountPath: /opt/app/media | ||
- name: log-volume | ||
mountPath: /var/log/django/ | ||
|
||
volumes: | ||
- name: static-volume | ||
hostPath: | ||
path: /opt/portal/data/static | ||
- name: media-volume | ||
hostPath: | ||
path: /opt/portal/data/media | ||
- name: log-volume | ||
hostPath: | ||
path: /opt/portal/logs/django |
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,56 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: portal-nginx | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: "http-port" | ||
port: 80 | ||
targetPort: 80 | ||
nodePort: 30080 | ||
selector: | ||
app: portal-nginx | ||
|
||
--- | ||
|
||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: portal-nginx | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: portal-nginx | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: portal-nginx | ||
spec: | ||
containers: | ||
- image: isucon/portal-nginx:latest | ||
imagePullPolicy: IfNotPresent | ||
name: portal-nginx | ||
ports: | ||
- containerPort: 80 | ||
name: portal-nginx | ||
volumeMounts: | ||
- name: static-volume | ||
mountPath: /opt/app/static | ||
- name: media-volume | ||
mountPath: /opt/app/media | ||
- name: log-volume | ||
mountPath: /var/log/nginx/ | ||
|
||
volumes: | ||
- name: static-volume | ||
hostPath: | ||
path: /opt/portal/data/static | ||
- name: media-volume | ||
hostPath: | ||
path: /opt/portal/data/media | ||
- name: log-volume | ||
hostPath: | ||
path: /opt/portal/logs/nginx |
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,4 @@ | ||
FROM nginx:latest | ||
|
||
ADD nginx.conf /etc/nginx/ | ||
ADD conf.d/ /etc/nginx/conf.d/ |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
upstream portal { | ||
server django:5000; | ||
server portal-app:5000; | ||
keepalive 128; | ||
} | ||
|
||
|