Skip to content

Commit

Permalink
Add setting of ingress (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
chimame authored Sep 28, 2018
1 parent dbd771d commit 735a580
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 80 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM ruby:2.4.4-alpine3.7

ENV LANG C.UTF-8
ENV BUNDLE_FORCE_RUBY_PLATFORM 1

RUN apk update && apk upgrade && apk add --update --no-cache alpine-sdk tzdata postgresql-dev nodejs postgresql-client
RUN mkdir /app
WORKDIR /app
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ gem 'puma', '~> 3.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# health check of Rails app
gem "health_check"

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ GEM
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
hashie (3.5.6)
health_check (3.0.0)
railties (>= 5.0)
i18n (0.9.0)
concurrent-ruby (~> 1.0)
interception (0.5)
Expand Down Expand Up @@ -317,6 +319,7 @@ DEPENDENCIES
faker
forgery_ja
guard-rspec
health_check
listen (>= 3.0.5, < 3.2)
omniauth-facebook
omniauth-github
Expand Down Expand Up @@ -349,4 +352,4 @@ RUBY VERSION
ruby 2.4.4p296

BUNDLED WITH
1.16.1
1.16.5
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

Rails.application.routes.draw do
health_check_routes
mount_devise_token_auth_for 'User', at: 'auth'
resources :communities, shallow: true, defaults: { format: 'json' } do
resources :events do
Expand Down
4 changes: 3 additions & 1 deletion docs/DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ $ kubectl create -f kubernetes/postgresql-service.yml
$ export TEBUKURO_IMAGE=us.gcr.io/tebukuro-182304/tebukuro_backend:latest
$ cat kubernetes/tebukuro.yml | envsubst | kubectl create -f -
# create tebukuro service
$ kubectl create -f kubernetes/nginx-service.yml
$ kubectl create -f kubernetes/tebukuro-service.yml
# create tebukuro ingress
$ kubectl create -f kubernetes/ingress.yml
```

## Deploy(migrate) task
Expand Down
8 changes: 8 additions & 0 deletions kubernetes/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: tebukuro-ingress
spec:
backend:
serviceName: tebukuro
servicePort: 3000
17 changes: 0 additions & 17 deletions kubernetes/nginx-service.yml

This file was deleted.

3 changes: 0 additions & 3 deletions kubernetes/nginx/Dockerfile

This file was deleted.

42 changes: 0 additions & 42 deletions kubernetes/nginx/nginx.conf

This file was deleted.

14 changes: 14 additions & 0 deletions kubernetes/tebukuro-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: tebukuro
labels:
app: tebukuro
spec:
type: NodePort
ports:
- port: 3000
targetPort: 3000
protocol: TCP
selector:
app: tebukuro
20 changes: 4 additions & 16 deletions kubernetes/tebukuro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ spec:
labels:
app: tebukuro
spec:
volumes:
- name: web-sock
emptyDir: {}
containers:
- image: $TEBUKURO_IMAGE
name: tebukuro
Expand Down Expand Up @@ -55,17 +52,8 @@ spec:
ports:
- containerPort: 3000
name: tebukuro
readinessProbe:
httpGet:
path: /health_check.json
port: 3000
command: ["/app/script/wait.sh", "bundle", "exec", "rails", "s"]
volumeMounts:
- mountPath: /app/tmp/sockets
name: web-sock
- image: us.gcr.io/tebukuro-182304/nginx:0.0.1
name: nginx
ports:
- name: http-server
containerPort: 80
- name: https-server
containerPort: 443
volumeMounts:
- mountPath: /app/tmp/sockets
name: web-sock
6 changes: 6 additions & 0 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ $(cd $(dirname ${BASH_SOURCE:-$0}); pwd)/migrate-job.sh
cat kubernetes/tebukuro.yml | envsubst | kubectl apply -f -
kubectl describe deployment tebukuro
kubectl rollout status deployment/tebukuro

kubectl apply -f kubernetes/tebukuro-service.yml
kubectl describe service tebukuro

kubectl apply -f kubernetes/ingress.yml
kubectl describe ingress tebukuro-ingress

0 comments on commit 735a580

Please sign in to comment.