Skip to content

Commit

Permalink
feat: add kong configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sujeet-agrahari committed Feb 20, 2024
1 parent 7602a39 commit e59e3ae
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 365 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,37 @@ REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h 127.0.0.1 -p 6379

### Setup Kubernetes Dashboard

#### Using Helm

```sh
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard

```

Get the Kubernetes Dashboard URL by running:

```sh
export POD_NAME=$(kubectl get pods -n kubernetes-dashboard -l "app.kubernetes.io/name=kubernetes-dashboard,app.kubernetes.io/instance=kubernetes-dashboard" -o jsonpath="{.items[0].metadata.name}")
echo https://127.0.0.1:8443/
kubectl -n kubernetes-dashboard port-forward $POD_NAME 8443:8443
```

#### Without Using Helm

- Create a service account

```sh
kubectl apply -f ./kubernetes/service-accounts/k8s-dashboard.service-account.yaml
kubectl apply -f kubernetes/k8s-dashboard/k8s-dashboard.service-account.yaml
```

- Create cluster-level role binding
```sh
kubectl apply -f ./kubernetes/service-accounts/k8s-cluster-level.role-binding.yaml
```
We can also create a role-binding for a namespace
```sh
kubectl apply -f ./kubernetes/service-accounts/k8s-dashboard.role-binding.yaml
kubectl apply -f kubernetes/k8s-dashboard/k8s-dashboard.role-binding.yaml
```
- Generate access token for a service account

Expand Down
25 changes: 25 additions & 0 deletions deploy/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: quick-links-argocd-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/sujeet-agrahari/quick-links.git
targetRevision: HEAD
path: deploy/quick-links-charts
destination:
server: https://kubernetes.default.svc
namespace: quick-links
syncPolicy:
syncOptions:
- CreateNamespace=true
automated: true
selfHeal: true
prune: true





File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ deployment:
replicaCount: 2
image:
repository: quick-links
tag: prod
tag: dev
pullPolicy: Never
env:
DB_HOST: 'postgres-postgresql-ha-pgpool'
Expand Down
7 changes: 7 additions & 0 deletions kubernetes/command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# switch to namespace
kubectl config set-context --current --namespace=default

# get the current switched namespace
kubectl config view --minify --output 'jsonpath={..namespace}'

kubectl config view | grep namespace
46 changes: 0 additions & 46 deletions kubernetes/deployment.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions kubernetes/k8s-dashboard/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#will create kubernetes-dashboard namespace
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml


# Link

# http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:https/proxy/#/login

# create token
kubectl create token dashboard-sa | pbcopy


# for cluster roles
# https://surajblog.medium.com/simplified-deployment-of-kubernetes-dashboard-with-alb-ingress-controller-bf3396c0dc54
26 changes: 26 additions & 0 deletions kubernetes/kong/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# default namesapce
helm install kong kong/kong --set admin.useTLS=false,admin.enabled=true,admin.http.enabled=true,env.admin_gui_path=/kong-manager,env.admin_gui_url=http://localhost/kong-manager,env.admin_gui_api_url=http://localhost/kong-admin



# enable kong admin api
kubectl port-forward svc/kong-kong-admin 8001:8001

# enable kong manager
kubectl port-forward svc/kong-kong-manager 8002:8002



# Better way change the path of admin and manager

helm install kong kong/kong --set admin.useTLS=false,admin.enabled=true,admin.http.enabled=true,manager.ingress.path=/kong-manager,admin.ingress.path=/kong-admin,manager.ingress.enabled=true,admin.ingress.enabled=true


# upgrade values

helm upgrade kong kong/kong --set admin.useTLS=false,admin.enabled=true,admin.http.enabled=true,manager.ingress.path=/kong-manager,admin.ingress.path=/kong-admin,manager.ingress.enabled=true,admin.ingress.enabled=true

helm install kong kong/kong --set admin.useTLS=false,admin.enabled=true,admin.http.enabled=true,env.admin_gui_path=/kong-manager,env.admin_gui_url=http://localhost/kong-manager,env.admin_gui_api_url=http://localhost/kong-admin

# https://jaygorrell.medium.com/kubernetes-ingress-82aa960f658e
20 changes: 20 additions & 0 deletions kubernetes/kong/k8s-dashboard.ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-dashboard-ingress
annotations:
kubernetes.io/ingress.class: 'kong'
konghq.com/strip-path: 'true'
namespace: kubernetes-dashboard
spec:
rules:
- host: localhost
http:
paths:
- path: /dashboard
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 80
19 changes: 19 additions & 0 deletions kubernetes/kong/kong-admin-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kong-admin-ingress
annotations:
kubernetes.io/ingress.class: 'kong'
konghq.com/strip-path: 'true'
spec:
rules:
- host: localhost
http:
paths:
- path: /kong-admin
pathType: Prefix
backend:
service:
name: kong-kong-admin
port:
number: 8001
19 changes: 19 additions & 0 deletions kubernetes/kong/kong-manager-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kong-manager-ingress
annotations:
kubernetes.io/ingress.class: 'kong'
konghq.com/strip-path: 'false'
spec:
rules:
- host: localhost
http:
paths:
- path: /kong-manager
pathType: Prefix
backend:
service:
name: kong-kong-manager
port:
number: 8002
21 changes: 0 additions & 21 deletions kubernetes/kong/quick-link-kong-route.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: kong
spec:
controller: ingress-controllers.konghq.com/kong
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: quick-links-ingress
annotations:
kubernetes.io/ingress.class: kong
kubernetes.io/ingress.class: 'kong'
konghq.com/strip-path: 'true'
spec:
rules:
- http:
- host: localhost
http:
paths:
- path: /quick-links
pathType: Prefix
backend:
service:
name: quick-links-service
port:
name: quick-links
number: 3000
Loading

0 comments on commit e59e3ae

Please sign in to comment.