-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(k8s): support custom hostnames and TLS certs
- Loading branch information
Showing
92 changed files
with
2,578 additions
and
668 deletions.
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
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
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 |
---|---|---|
@@ -1,32 +1,72 @@ | ||
## Running against a remote Kubernetes cluster | ||
# Running against a remote Kubernetes cluster | ||
|
||
### Setup | ||
## Setup | ||
|
||
You need to have a running ingress controller on your cluster to route requests to | ||
the deployed services. This can generally be any controller of your choosing, such | ||
as the nginx ingress controller. | ||
### Connecting to the cluster | ||
|
||
You also need a configured [context](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) | ||
on your development machine. | ||
Start by making sure you have a [kubectl context](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) | ||
set up on your development machine to access your cluster. | ||
|
||
Then all you need to do is configure the environment and provider in your project | ||
`garden.yml`. You need to specify your configured context and the hostname of your | ||
ingress controller. Example: | ||
Then configure the project and provider, along with the kubectl context you use to connect to your | ||
cluster. | ||
|
||
Example: | ||
|
||
```yaml | ||
project: | ||
name: my-project | ||
environments: | ||
- name: dev | ||
providers: | ||
- name: kubernetes | ||
context: my-dev-context # the name of the kubectl context for the cluster | ||
defaultEnvironment: dev | ||
``` | ||
### Ingress, TLS and DNS | ||
The cluster needs to have a configured [nginx ingress controller](https://github.com/kubernetes/ingress-nginx). | ||
You'll also need to configure one or more TLS certificates for the hostnames you will expose for ingress. | ||
Once you have the certificates on hand (the `.crt` and `.key` files), create a | ||
[Secret](https://kubernetes.io/docs/concepts/configuration/secret/) for each cert in the cluster so that | ||
they can be referenced when deploying services: | ||
|
||
```sh | ||
kubectl create secret tls mydomain-tls-secret --key <path-to-key-file> --cert <path-to-crt-file> | ||
``` | ||
|
||
Then configure each certificate/secret in your provider configuration: | ||
|
||
```yaml | ||
project: | ||
name: my-project | ||
environments: | ||
dev: | ||
providers: | ||
kubernetes: | ||
context: my-dev-context | ||
ingressHostname: k8s-dev.mydomain.com | ||
ingressClass: nginx # this is optional, but may be necessary for your ingress controller configuration | ||
- name: dev | ||
providers: | ||
- name: kubernetes | ||
context: my-dev-context | ||
tlsCertificates: | ||
- name: main | ||
# Optionally set particular hostnames to use this certificate for | ||
# (useful if you have multiple certs for the same hostname). | ||
hostnames: [mydomain.com] | ||
secretRef: | ||
# Change to whatever name you chose for the secret above. | ||
name: my-tls-secret | ||
# Change this if you store the secret in another namespace. | ||
namespace: default | ||
- name: wildcard | ||
secretRef: | ||
name: wildcard-tls-secret | ||
namespace: default | ||
defaultEnvironment: dev | ||
``` | ||
|
||
Note that you need to have permissions to create namespaces and to create deployments, | ||
daemonsets, services and ingresses within the namespaces created. The plugin will | ||
create two namespaces per user and project, one to run services and another to manage | ||
metadata and configuration (this is so that your environment can be reset without | ||
clearing your configuration variables). | ||
### Permissions | ||
|
||
Note that you need to have permissions to create namespaces and to create deployments, | ||
daemonsets, services and ingresses within the namespaces created. The plugin will | ||
create two or more namespaces per user and project, one to run services, another to manage | ||
metadata and configuration (this is so that your environment can be reset without | ||
clearing your configuration variables), and potentially more to support specific plugins/providers. |
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
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
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
Oops, something went wrong.