Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
astrocket committed Apr 19, 2020
1 parent 2390ec7 commit 7fbbf77
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions k8s/README.md.tt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ kubectl create -f k8s/cluster/lets_encrypt_issuer.yaml

Create Demo Ingress, Service, Pod. (to test configuration)

[k8s/demo.yaml](k8s/demo.yaml)

```bash
kubectl apply -f k8s/demo.yaml
```
Expand Down Expand Up @@ -182,13 +184,17 @@ It's recommended to manage resources seperately to prevent downtime while updati
* `k8s/project/<%= k8s_name %>-nginx-conf.yaml` creates application level nginx's(* is different from ingress-nginx*) config-map, where we serve static files, redirect app traffic to puma. (It will be used when deploying k8s/app.yaml)

```bash
kubectl apply -f k8s/project/<%= k8s_name %>-nginx-conf.yaml
kubectl apply -f k8s/web.yaml
kubectl apply -f k8s/sidekiq.yaml
kubectl apply -f k8s/ingress.yaml
kubectl create secret generic <%= k8s_name %>-secrets --from-file=<%= k8s_name %>-master-key=config/master.key # push master.key to k8s secret
kubectl apply -f k8s/ingress.yaml # from load-balancer to web service
kubectl apply -f k8s/service.yaml # web service for web deployment
kubectl apply -f k8s/project/<%= k8s_name %>-nginx-conf.yaml # for web deployment's nginx
kubectl apply -f k8s/web.yaml # puma & nginx
kubectl apply -f k8s/sidekiq.yaml # sidekiq
... etc
```

## Extra

### Monitoring Commands

#### Pod
Expand Down Expand Up @@ -219,7 +225,7 @@ rails deploy:logs:web
rails deploy:logs:sidekiq
```

### Deployment Script
### Rails Tasks

Execute multiple kubectl commands with rails task.

Expand All @@ -229,7 +235,7 @@ rails deploy:demo:up
rails deploy:demo:down # rollback

# push master.key to kubernetes secret
rails deploy:production:set_maseter_key
rails deploy:production:set_master_key

# apply production application nginx config
# apply production ingress
Expand Down Expand Up @@ -278,9 +284,9 @@ delete secrets
kb delete secret <%= k8s_name %>-secrets
```

## Tuning
### Tuning

### Puma
#### Puma

`process * thread * pod replicas < db connection`

Expand All @@ -292,7 +298,7 @@ kb delete secret <%= k8s_name %>-secrets

You can customize application nginx through [config-map](k8s/project/<%= k8s_name %>-nginx-conf.yaml) as usual.

### Ingress Nginx
#### Ingress Nginx

To make your service scalable, you should consider tuning your [ingress-nginx](https://kubernetes.github.io/ingress-nginx) as your needs.

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/deploy.rake.tt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace :deploy do
sh("docker push #{image_tag}")
end

task :set_maseter_key => :environment do
task :set_master_key => :environment do
sh("kubectl create secret generic <%= k8s_name %>-secrets --from-file=<%= k8s_name %>-master-key=config/master.key")
end

Expand Down

0 comments on commit 7fbbf77

Please sign in to comment.