Skip to content

Commit

Permalink
Juliens/ingress and charts (#8)
Browse files Browse the repository at this point in the history
* add docs

* add gitignore rules

* update charts

* update favicon
  • Loading branch information
julienstroheker authored Jan 30, 2020
1 parent 7e18337 commit 4f9ee81
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 103 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
node_modules
bin
ihaq-*
.env
.env
**.pub
juihaq
sshkey
id_rsa
28 changes: 10 additions & 18 deletions charts/api/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "api.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
###################################################
############## IHAQ API running ! ##############
###################################################
###### Logs :
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "api.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl logs $POD_NAME --namespace {{ .Release.Namespace }}
###### Service :
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "api.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "api.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "api.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
###################################################
###################################################
2 changes: 1 addition & 1 deletion charts/api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["-redis-server-name", "api-redis-master"]
args: ["-redis-server-name", "ihaq-api-redis-master"]
ports:
- name: http
containerPort: 8080
Expand Down
28 changes: 10 additions & 18 deletions charts/client/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "client.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
###################################################
############## IHAQ Client running ! ##############
###################################################
###### Logs :
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "client.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl logs $POD_NAME --namespace {{ .Release.Namespace }}
###### Service :
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "client.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "client.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "client.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
###################################################
###################################################
2 changes: 1 addition & 1 deletion charts/client/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["-i", "192.168.64.2:31834"]
args: ["-i", "api.ihaq.juin.me"]
ports:
- name: http
containerPort: 80
Expand Down
41 changes: 0 additions & 41 deletions charts/client/templates/ingress.yaml

This file was deleted.

21 changes: 5 additions & 16 deletions charts/client/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template
name:

podSecurityContext: {}
podSecurityContext:
{}
# fsGroup: 2000

securityContext: {}
securityContext:
{}
# capabilities:
# drop:
# - ALL
Expand All @@ -35,22 +37,9 @@ securityContext: {}
# runAsUser: 1000

service:
type: NodePort
type: LoadBalancer
port: 80

ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
Expand Down
22 changes: 22 additions & 0 deletions charts/ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: ingress
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: api.ihaq.juin.me
http:
paths:
- path: /
backend:
serviceName: ihaq-api
servicePort: 8080
- host: ihaq.juin.me
http:
paths:
- path: /
backend:
serviceName: ihaq-client
servicePort: http
13 changes: 13 additions & 0 deletions charts/ingress/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dashboard:
enabled: true
domain: dashboard.juin.me
auth:
basic:
julien: $apr1$4hq6z3e8$nXeunzoTgvUfcHslqQPAY. # Generated by htpasswd tool
kubernetes:
namespaces:
- default
- kube-system

rbac:
enabled: true
2 changes: 1 addition & 1 deletion charts/worker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["-redis-server-name", "api-redis-master"]
args: ["-redis-server-name", "ihaq-api-redis-master"]
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand Down
Binary file modified cmd/web/public/favicon.ico
Binary file not shown.
5 changes: 1 addition & 4 deletions cmd/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="I Have A Question ?" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand Down
Binary file modified cmd/web/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cmd/web/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions cmd/web/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "IHAQ",
"name": "I Have A Question ?",
"icons": [
{
"src": "favicon.ico",
Expand Down
20 changes: 20 additions & 0 deletions docs/deploy-aks-cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Deploy an AKS Cluster

> Install helm
> az aks install-cli
```bash
export AKS_SUB_ID=<YourSubID>
export AKS_SSH_KEY=<LocationToYourPublicKey>
export AKS_RG_NAME=<YourRGName>
export AKS_CLUSTER_NAME=<YourClusterName>


az login
az account -set $AKS_SUB_ID
az aks create -n $AKS_CLUSTER_NAME -g $AKS_RG_NAME --ssh-key-value $AKS_SSH_KEY

az aks get-credentials -n $AKS_CLUSTER_NAME -g $AKS_RG_NAME

helm repo add stable https://kubernetes-charts.storage.googleapis.com/
```
25 changes: 25 additions & 0 deletions docs/setup-k8s-cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Setup your Kubernetes Cluster

## Deploy the app

```bash
helm install ihaq-api charts/api --set redis.usePassword=false
helm install ihaq-worker charts/worker
helm install ihaq-client charts/client
```

Validate your deployment `kubectl get pods`

## Deploy Ingress

```bash
# Deploy Traefik
helm install traefik --namespace kube-system --values charts/ingress/values.yaml stable/traefik
# Apply Ingress rules
kubectl apply -f charts/ingress/ingress.yaml
```

Get the traefix External IP using `kubectl get svc -n kube-system` command and add the following DNS record to your zone :
- dashboard
- api.ihaq
- ihaq

0 comments on commit 4f9ee81

Please sign in to comment.