Code Monkey home page Code Monkey logo

kong-ingress-controller's Introduction

kind-kong

Dependencies

Install kubectl and helm using asdf

asdf plugin add kubectl
asdf plugin add helm
asdf install

Repository configuration

Because in this tutorial we are going to use ArgoCD it's recommended to fork the original project to your personal GitHub account.

Once the fork has completed, edit the following files replacing the repoURL variable to your GitHub profile.

git clone [email protected]:<username>/kind-kong.git

# Edit files
# - config/argocd-foo-bar-app.yaml
# - config/argocd-httpbin-app.yaml
# - resources/argocd-app-of-apps.yaml

git add config
git commit -m "Update repoURL to my local GitHub"
git push origin main

Create Kind cluster

kind create cluster --name kong --config=resources/kind.yaml
kind get kubeconfig --name kong > ~/.kube/kind-kong-config

Setup kubectl

# Setup kubeconfig
export KUBECONFIG=~/.kube/kind-kong-config

# Testing configuration
kubectl get nodes

MetalLB setup address pool used by loadbalancers

To complete layer2 configuration, we need to provide metallb a range of IP addresses it controls. We want this range to be on the docker kind network.

docker network inspect -f '{{.IPAM.Config}}' kind

Edit the file argocd-metallb.yaml adding the ip range you want.

Setup /etc/hosts

/etc/hosts

192.168.32.2	httpbin.local
192.168.32.2	grafana.local
192.168.32.2	prometheus.local
192.168.32.2	argocd.local

Install ArgoCD

helm repo add argo https://argoproj.github.io/argo-helm
helm repo update

helm install argo-cd argo/argo-cd --create-namespace --namespace argocd --version 4.5.7 --values resources/argocd-values.yaml

# Check pods
kubectl get pod -n argocd --watch

Login to argocd

The initial password for the admin account is auto-generated and stored as clear text in the field password in a secret named argocd-initial-admin-secret in your Argo CD installation namespace.

You can simply retrieve this password using kubectl:

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

Port Forwarding

On a secondary terminal

kubectl port-forward service/argo-cd-argocd-server -n argocd 8080:443

Go to the argocd webpage https://localhost:8080 and sync the Argo Application app-of-apps.

Deploy app of apps

kubectl -n argocd apply -f resources/argocd-app-of-apps.yaml

Expose argocd with kong

kubectl -n argocd patch deployment argo-cd-argocd-server --type json \
    -p='[ { "op": "replace", "path":"/spec/template/spec/containers/0/command","value": ["argocd-server","--staticassets","/shared/app","--repo-server","argo-cd-argocd-repo-server:8081","--dex-server","http://argo-cd-argocd-dex-server:5556","--logformat","text","--loglevel","info","--redis","argo-cd-argocd-redis:6379","--insecure"] }]'

This command could take some time to reload the Pod.

Services URLs

Deploy native plugins

kubectl apply -n httpbin -f kong-plugins/rate-limiting.yaml
kubectl apply -f kong-plugins/prometheus.yaml

Custom plugin

The custom plugin is located at myheader folder.

Create a ConfigMap or Secret with the plugin code

Next, we are going to create a ConfigMap or Secret based on the plugin code.

Please ensure that this is created in the same namespace as the one in which Kong is installed.

# using ConfigMap; replace `myheader` with the name of your plugin
kubectl create configmap kong-plugin-myheader --from-file=myheader -n kong

# OR using Secret
kubectl create secret generic -n kong kong-plugin-myheader --from-file=myheader

Install plugin Kong

Edit/uncomment the Kong deployment configuration to install the custom plugin under config/argocd-kong.yaml

kong-custom-plugin-install

Add, commit and push your changes to your remote git repository.

git add config/argocd-kong.yaml
git commit -m "configure myheader custom kong plugin"
git push origin main

Then reload Kong deployment inside ArgoCD.

Apply the CRD to kubernetes API.

kubectl apply -n httpbin -f kong-plugins/custom.yaml

Cleanup Kind

kind delete cluster --name kong

Author

Managed by Arthur Diniz and Claudio Oliveira.

License

Apache 2 Licensed. See LICENSE for full details.

kong-ingress-controller's People

Contributors

arthurbdiniz avatar lycan-nt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.