This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Mashape/minikube
Run Kong on locally provisioned K8 cluster
- Loading branch information
Showing
6 changed files
with
368 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ Kong can easily be provisioned to Kubernetes cluster using the following steps: | |
$ git clone [email protected]:Mashape/kong-dist-kubernetes.git | ||
$ cd kong-dist-kubernetes | ||
``` | ||
If you want to run Kubernetes locally, please follow the [README](/minikube) | ||
in `minikube` subfolder. | ||
|
||
Skip to step 3 if you have already provisioned a cluster and registered it | ||
with Kubernetes. | ||
|
@@ -26,7 +28,7 @@ Kong can easily be provisioned to Kubernetes cluster using the following steps: | |
You need [gcloud](https://cloud.google.com/sdk/) and | ||
[kubectl]https://cloud.google.com/container-engine/docs/quickstart#install_the_gcloud_command-line_interface) | ||
command-line tools installed and set upto run deployment commands. | ||
Also make sure your Google Cloud account has atleast two `STATIC_ADDRESSES` available. | ||
Also make sure your Google Cloud account has atleast two `STATIC_ADDRESSES` available. | ||
|
||
Using the `cluster.yaml` file from this repo, deploy a | ||
GKE cluster. Provide the following information before deploying: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
Kong can easily be provisioned to Minikube cluster using the following steps: | ||
|
||
1. **Deploy Kubernetes via Minikube** | ||
|
||
You need [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) and | ||
[kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) | ||
command-line tools installed and set up to run deployment commands. | ||
|
||
Using the `minikube` command, deploy a Kubernetes cluster. | ||
|
||
```bash | ||
$ minikube start | ||
``` | ||
|
||
By now, you have provisioned a Kubernetes managed cluster locally. | ||
|
||
2. **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 `ReplicationController` in the cluster: | ||
|
||
```bash | ||
$ kubectl create -f cassandra.yaml | ||
``` | ||
|
||
For PostgreSQL, use the `postgres.yaml` file from the kong-dist-kubernetes | ||
repo to deploy a PostgreSQL `Service` and a `ReplicationController` in the | ||
cluster: | ||
|
||
```bash | ||
$ kubectl create -f postgres.yaml | ||
``` | ||
|
||
3. **Deploy Kong** | ||
|
||
Using the `kong_<postgres|cassandra>.yaml` file from this repo, deploy | ||
a Kong `Service` and a `Deployment` to the cluster created in the last step: | ||
|
||
```bash | ||
$ kubectl create -f kong_<postgres|cassandra>.yaml | ||
``` | ||
|
||
4. **Verify your deployments** | ||
|
||
You can now see the resources that have been deployed using `kubectl`: | ||
|
||
```bash | ||
$ kubectl get rc | ||
$ kubectl get deployment | ||
$ kubectl get pods | ||
$ kubectl get services | ||
$ kubectl get logs <pod-name> | ||
``` | ||
|
||
Once the kong-admin and kong-proxy pods are started, you | ||
can test Kong by making the following requests: | ||
|
||
```bash | ||
$ curl $(minikube service --url kong-admin) | ||
$ curl $(minikube service --url kong-proxy|head -n1) | ||
``` | ||
|
||
It may take up to 3 minutes for all services to come up. | ||
|
||
5. **Using Kong** | ||
|
||
Quickly learn how to use Kong with the | ||
[5-minute Quickstart](https://getkong.org/docs/latest/getting-started/quickstart/). | ||
|
||
## Important Note | ||
|
||
When deploying into a Kubernetes cluster with Deployment Manager, it is | ||
important to be aware that deleting `ReplicationController` Kubernetes objects | ||
**does not delete its underlying pods**, and it is your responisibility to | ||
manage the destruction of these resources when deleting or updating a | ||
`ReplicationController` in your configuration. | ||
|
||
|
||
## Enterprise Support | ||
|
||
Support, Demo, Training, API Certifications and Consulting available at http://getkong.org/enterprise. | ||
|
||
[kong-logo]: http://i.imgur.com/4jyQQAZ.png | ||
[website-url]: https://getkong.org/ | ||
[website-badge]: https://img.shields.io/badge/GETKong.org-Learn%20More-43bf58.svg | ||
[documentation-url]: https://getkong.org/docs/ | ||
[documentation-badge]: https://img.shields.io/badge/Documentation-Read%20Online-green.svg | ||
[gitter-url]: https://gitter.im/Mashape/kong | ||
[gitter-badge]: https://img.shields.io/badge/Gitter-Join%20Chat-blue.svg | ||
[mailing-list-badge]: https://img.shields.io/badge/Email-Join%20Mailing%20List-blue.svg | ||
[mailing-list-url]: https://groups.google.com/forum/#!forum/konglayer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cassandra | ||
spec: | ||
ports: | ||
- name: cql | ||
port: 9042 | ||
targetPort: 9042 | ||
protocol: TCP | ||
selector: | ||
app: cassandra | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ReplicationController | ||
metadata: | ||
name: cassandra | ||
# The labels will be applied automatically | ||
# from the labels in the pod template, if not set | ||
# labels: | ||
# app: cassandra | ||
spec: | ||
replicas: 3 | ||
# The selector will be applied automatically | ||
# from the labels in the pod template, if not set. | ||
# selector: | ||
# app: cassandra | ||
template: | ||
metadata: | ||
labels: | ||
app: cassandra | ||
spec: | ||
containers: | ||
- command: | ||
- /run.sh | ||
resources: | ||
limits: | ||
cpu: 0.5 | ||
env: | ||
- name: MAX_HEAP_SIZE | ||
value: 512M | ||
- name: HEAP_NEWSIZE | ||
value: 100M | ||
- name: CASSANDRA_SEED_PROVIDER | ||
value: "io.k8s.cassandra.KubernetesSeedProvider" | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
image: gcr.io/google-samples/cassandra:v11 | ||
name: cassandra | ||
ports: | ||
- containerPort: 7000 | ||
name: intra-node | ||
- containerPort: 7001 | ||
name: tls-intra-node | ||
- containerPort: 7199 | ||
name: jmx | ||
- containerPort: 9042 | ||
name: cql | ||
volumeMounts: | ||
- mountPath: /cassandra_data | ||
name: data | ||
volumes: | ||
- name: data | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kong-proxy | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: kong-proxy | ||
port: 8000 | ||
targetPort: 8000 | ||
protocol: TCP | ||
- name: kong-proxy-ssl | ||
port: 8443 | ||
targetPort: 8443 | ||
protocol: TCP | ||
selector: | ||
app: kong | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kong-admin | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: kong-admin | ||
port: 8001 | ||
targetPort: 8001 | ||
protocol: TCP | ||
selector: | ||
app: kong | ||
|
||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: kong-rc | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: kong-rc | ||
app: kong | ||
spec: | ||
containers: | ||
- name: kong | ||
image: kong | ||
env: | ||
- name: KONG_DATABASE | ||
value: cassandra | ||
- name: KONG_CASSANDRA_CONTACT_POINTS | ||
value: cassandra.default.svc.cluster.local | ||
- name: KONG_CASSANDRA_KEYSPACE | ||
value: kong | ||
- name: KONG_CASSANDRA_REPL_FACTOR | ||
value: "2" | ||
- name: KONG_HOST_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
command: [ "/bin/sh", "-c", "KONG_CLUSTER_ADVERTISE=$(KONG_HOST_IP):7946 KONG_NGINX_DAEMON='off' kong start" ] | ||
ports: | ||
- name: admin | ||
containerPort: 8001 | ||
protocol: TCP | ||
- name: proxy | ||
containerPort: 8000 | ||
protocol: TCP | ||
- name: proxy-ssl | ||
containerPort: 8443 | ||
protocol: TCP | ||
- name: surf-tcp | ||
containerPort: 7946 | ||
protocol: TCP | ||
- name: surf-udp | ||
containerPort: 7946 | ||
protocol: UDP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kong-proxy | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: kong-proxy | ||
port: 8000 | ||
targetPort: 8000 | ||
protocol: TCP | ||
- name: kong-proxy-ssl | ||
port: 8443 | ||
targetPort: 8443 | ||
protocol: TCP | ||
selector: | ||
app: kong | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kong-admin | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: kong-admin | ||
port: 8001 | ||
targetPort: 8001 | ||
protocol: TCP | ||
selector: | ||
app: kong | ||
|
||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: kong-rc | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: kong-rc | ||
app: kong | ||
spec: | ||
containers: | ||
- name: kong | ||
image: kong | ||
env: | ||
- name: KONG_PG_PASSWORD | ||
value: kong | ||
- name: KONG_PG_HOST | ||
value: postgres.default.svc.cluster.local | ||
- name: KONG_HOST_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
command: [ "/bin/sh", "-c", "KONG_CLUSTER_ADVERTISE=$(KONG_HOST_IP):7946 KONG_NGINX_DAEMON='off' kong start" ] | ||
ports: | ||
- name: admin | ||
containerPort: 8001 | ||
protocol: TCP | ||
- name: proxy | ||
containerPort: 8000 | ||
protocol: TCP | ||
- name: proxy-ssl | ||
containerPort: 8443 | ||
protocol: TCP | ||
- name: surf-tcp | ||
containerPort: 7946 | ||
protocol: TCP | ||
- name: surf-udp | ||
containerPort: 7946 | ||
protocol: UDP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: postgres | ||
spec: | ||
ports: | ||
- name: pgql | ||
port: 5432 | ||
targetPort: 5432 | ||
protocol: TCP | ||
selector: | ||
app: postgres | ||
--- | ||
apiVersion: v1 | ||
kind: ReplicationController | ||
metadata: | ||
name: postgres | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: postgres | ||
spec: | ||
containers: | ||
- name: postgres | ||
image: postgres:9.4 | ||
env: | ||
- name: POSTGRES_USER | ||
value: kong | ||
- name: POSTGRES_PASSWORD | ||
value: kong | ||
- name: POSTGRES_DB | ||
value: kong | ||
- name: PGDATA | ||
value: /var/lib/postgresql/data/pgdata | ||
ports: | ||
- containerPort: 5432 | ||
volumeMounts: | ||
- mountPath: /var/lib/postgresql/data | ||
name: pg-data | ||
volumes: | ||
- name: pg-data | ||
emptyDir: {} |