Skip to content

Commit

Permalink
Create namespaced resources
Browse files Browse the repository at this point in the history
  • Loading branch information
sujeet-agrahari committed Feb 24, 2024
1 parent 4877cc4 commit 669ab72
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 39 deletions.
9 changes: 5 additions & 4 deletions deploy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ deployment:
replicaCount: 2
image:
repository: quick-links
tag: argocd
tag: dev
pullPolicy: Never
env:
DB_HOST: 'postgres-postgresql-ha-pgpool'
NODE_ENV: 'development'
DB_HOST: 'postgres-postgresql-ha-pgpool.postgres.svc.cluster.local'
DB_USER: 'postgres'
DB_PASSWORD: 'password'
DB_NAME: 'quicklink'
REDIS_HOST: 'redis-master'
REDIS_PASSWORD: 'pyL9vFnIpw'
REDIS_HOST: 'redis-master.redis.svc.cluster.local'
REDIS_PASSWORD: 'password'

service:
name: quick-links-service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dashboard-cluster-role
name: k8s-dashboard-cluster-role
rules:
- apiGroups: ['*']
resources: ['*']
Expand All @@ -10,12 +10,12 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dashboard-cluster-role-binding
name: k8s-dashboard-cluster-role-binding
subjects:
- kind: ServiceAccount
name: dashboard-sa
namespace: default
namespace: k8s-dashboard
roleRef:
kind: ClusterRole
name: dashboard-cluster-role
name: k8s-dashboard-cluster-role
apiGroup: rbac.authorization.k8s.io
12 changes: 0 additions & 12 deletions kubernetes/k8s-dashboard/k8s-dashboard.role-binding.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: dashboard-sa
namespace: k8s-dashboard
45 changes: 26 additions & 19 deletions step-wise-guideline.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,44 @@ helm install postgres bitnami/postgresql-ha \
--set global.postgresql.repmgrDatabase="repmgr" \
--set global.pgpool.adminUsername="admin" \
--set global.pgpool.adminPassword="password" \
--set postgresqlImage.debug=true
--set postgresqlImage.debug=true \
--create-namespace --namespace postgres
```

Once installed,

PostgreSQL can be accessed through Pgpool via port 5432 on the following DNS name from within your cluster:

```sh
postgres-postgresql-ha-pgpool.default.svc.cluster.local
postgres-postgresql-ha-pgpool.postgres.svc.cluster.local
```

To get the password for the `postgres` user run:

```sh
kubectl get secret --namespace default postgres-postgresql-ha-postgresql -o jsonpath="{.data.password}" | base64 -d | pbcopy
kubectl get secret --namespace postgres postgres-postgresql-ha-postgresql -o jsonpath="{.data.password}" | base64 -d | pbcopy
```

To connect to your database and test from outside the cluster execute the following commands:

```sh
kubectl port-forward --namespace default svc/postgres-postgresql-ha-pgpool 5433:5432
kubectl port-forward --namespace postgres svc/postgres-postgresql-ha-pgpool 5433:5432

# If you want to make accessible through th process, you can run in background process:

kubectl port-forward --namespace default svc/postgres-postgresql-ha-pgpool 5433:5432 &
kubectl port-forward --namespace postgres svc/postgres-postgresql-ha-pgpool 5433:5432 &
```

## Setup Redis cluster

```sh
# Install redis - single mast and multiple slaves
helm install redis bitnami/redis
helm install redis bitnami/redis --set global.redis.password="password" --create-namespace --namespace redis




# Redis® can be accessed on the following DNS names from within your cluster:
# Redis can be accessed on the following DNS names from within your cluster:

# redis-master.default.svc.cluster.local for read/write operations (port 6379)
# redis-replicas.default.svc.cluster.local for read-only operations (port 6379)
Expand All @@ -78,27 +79,33 @@ kubectl get secret --namespace default redis -o jsonpath="{.data.redis-password}

# To connect to your database from outside the cluster execute the following commands:

kubectl port-forward --namespace default svc/redis-master 6379:6379 &
kubectl port-forward --namespace redis svc/redis-master 6379:6379 &
```

## Setup Kubernetes dashboard

```sh
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/

helm install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
helm install k8s-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace k8s-dashboard

# To access the dashboard run the following command:
kubectl apply -f kubernetes/k8s-dashboard/k8s-dashboard.service-account.yaml
kubectl apply -f kubernetes/k8s-dashboard/k8s-dashboard.role-binding.yaml
kubectl apply -f kubernetes/k8s-dashboard/service-account.yaml
kubectl apply -f kubernetes/k8s-dashboard/cluster-role-and-binding.yaml


# Get the token
kubectl create token dashboard-sa | pbcopy
kubectl create token dashboard-sa -n k8s-dashboard | pbcopy

kubectl -n k8s-dashboard port-forward k8s-dashboard-pod-name 8443:8443


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



```

## Setup Kong
Expand All @@ -116,10 +123,10 @@ kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml


# to serve on http you need add toplevel
# Go to kubernetes dashboard and update the argocd-cm config map
# to serve on http you need add toplevel at indent metadata
# Go to kubernetes dashboard and update the argocd-cmd-params-cm config map
# data:
# server.insecure: true
# server.insecure: "true"
# server.rootpath: /argocd -> it is needed to run behind proxy

kubectl get secrets -n argocd argocd-initial-admin-secret -o yaml
Expand All @@ -134,16 +141,16 @@ echo NkZoc3E0RW45OTZDRDlJdg== | base64 --decode

```
kubectl apply -f kubernetes/kong/argocd-ingress.yaml
kubectl apply -f kubernetes/kong/kong-admin.yaml
kubectl apply -f kubernetes/kong/kong-manager.yaml
kubectl apply -f kubernetes/kong/kong-admin-ingress.yaml
kubectl apply -f kubernetes/kong/kong-manager-ingress.yaml
kubectl apply -f kubernetes/kong/quick-links-ingress.yaml
```

## Deploy the app using argo cd

```sh
# Make sure you build the app first
docker build . --target dev -t quick-links:argocd
docker build . --target dev -t quick-links:dev

kubectl apply -f deploy/argocd/application.yaml
kubectl apply -f deploy/application.yaml
```

0 comments on commit 669ab72

Please sign in to comment.