文章链接: https://github.com/Kong/kong-dist-kubernetes
Kong can easily be provisioned to Kubernetes cluster using the following steps:
Initial setup
Download or clone the following repo:
$ git clone [email protected]:Kong/kong-dist-kubernetes.git$cdkong-dist-kubernetes
If you want to run Kubernetes locally, please follow the README and use the manifest files provided in minikubedirectory.
Skip to step 3 if you have already provisioned a cluster and registered it with Kubernetes.
Note: Included manifest files only support Kong v0.11.x, for 0.10.x please checkout the tag 1.0.0
Deploy a GKE cluster
You need gcloud and kubectl command-line tools installed and configured to run deployment commands. Also make sure your Google Cloud account has STATIC_ADDRESSES available for the external access of Kong services.
Using the cluster.yaml file from this repo, deploy a GKE cluster. Provide the following information before deploying:
Desired cluster name
Zone in which to run the cluster
A basicauth username and password for authenticating the access to the cluster
$ gcloud deployment-manager deployments \
create cluster --config cluster.yaml
Fetch credentials for above created cluster
$ gcloud container clusters get-credentials NAME [--zone=ZONE,-zZONE] [GCLOUD_WIDE_FLAG …]
By now, you have provisioned a Kubernetes managed cluster.
Deploy a Kong supported database
Before deploying Kong, you need to provision a Cassandra or PostgreSQL pod.
For Cassandra, use the cassandra.yaml file from this repo to deploy a Cassandra Service and a StatefulSet in the cluster:
$ kubectl create -f cassandra.yaml
Note: Please update the cassandra.yaml file for the cloud you are working with.
For PostgreSQL, use the postgres.yaml file from the kong-dist-kubernetes repo to deploy a PostgreSQL Service and a ReplicationController in the cluster:
$ kubectl create -f postgres.yaml
Prepare database
Using the kong_migration_.yaml file from this repo, run the migration job, jump to step 5 if Kong backing databse is up–to–date:
$ kubectl create -f kong_migration_.yaml
Once job completes, you can remove the pod by running following command:
$ kubectl delete -f kong_migration_.yaml
Deploy Kong
Using the kong_.yaml file from this repo, deploy Kong admin and proxy services and a Deployment controller to the cluster:
$ kubectl create -f kong_.yaml
Verify your deployments
You can now see the resources that have been deployed using kubectl:
$ kubectl get all
Once the EXTERNAL_IP is available for Kong Proxy and Admin services, you can test Kong by making the following requests:
$ curl:8001$ curl https://:8444$ curl:8000$ curl https://:8443