-
Notifications
You must be signed in to change notification settings - Fork 5
/
apigateway_kong_konga.sh
64 lines (61 loc) · 2.3 KB
/
apigateway_kong_konga.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# configurar kong e konga
cd ~
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
kubectl create ns kong
helm install kong --set service.exposeAdmin=true --set service.type=NodePort --namespace kong bitnami/kong
kubectl get svc -n kong
git clone https://github.com/pantsel/konga.git && cd konga/charts/konga/
helm install konga -f ./values.yaml ../konga --set service.type=NodePort --namespace kong --wait
kubectl get svc konga -n kong
cd ~
export IP=$(curl -s checkip.amazonaws.com)
export PORT=$(kubectl -n kong get service kong -o jsonpath='{.spec.ports[?(@.name=="http-admin")].nodePort}')
# habilitar dashboard : https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
#kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml
# configurar rota para o dashboard
printf "\n\n"
echo " KONG : CONFIGURANDO ROTAS"
printf "\n\n"
curl -i -X POST --url http://$IP:$PORT/services/ --data 'name=dashboard' --data 'url=https://kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local'
curl -i -X POST --url http://$IP:$PORT/services/dashboard/routes --data 'paths[]=/dashboard'
curl -i -X POST --url http://$IP:$PORT/services/dashboard/routes --data 'paths[]=/'
# criando usuario de exemplo: https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
printf "\n\n"
echo " DASHBOARD : CONFIGURANDO TOKEN"
printf "\n\n"
# criar Conta
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: aluno
namespace: kubernetes-dashboard
EOF
# criar Permissão
cat <<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: aluno
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: aluno
namespace: kubernetes-dashboard
EOF
printf "\n\n"
echo " KONG : "
kubectl -n kong get service kong
printf "\n\n"
echo " KONGA UI : "
kubectl -n kong get service konga
printf "\n\n"
echo " TOKEN DASHBOARD : "
printf "\n\n"
# verificar Token
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep aluno | awk '{print $1}')