CUSTOM DOMAINS

Dan Pastusek
Apr 26, 2019

We're excited to announce support for custom domains on KubeSail! What this means is you can now expose your running containers under your own hostname, such as example.com rather than under the generated kubesail.io hostname. You can add as many domains as you'd like, even on the free tier!

To do this, you'll first need to verify your domain in the dashboard.

Exposing via the UI

Once verified, you'll find the domain you just added as an option when you click the Expose to Internet (HTTPS) button within the Ports tab of your DeploymentIn Kubernetes, a Deployment is an object which describes how an application is deployed. A Deployment defines the images to launch, how to configure them, and how they should be deployedRead More.... You may expose any subdomain of the domain you verified, so in the example below, we will expose api.stuffbydan.com even though we've only needed to verify the root domain, stuffbydan.com.

Exposing via kubectl

KubeSail currently uses Ambassador which allows you to create standard Kubernetes ServicesA Namespace is a logical group for application enviroments - staging, qa, production - a namespace isolates containers within it from containers outside.Read More... to route traffic based on hostname. To do this, you'll need to add an ambassador annotation to the ServiceA Namespace is a logical group for application enviroments - staging, qa, production - a namespace isolates containers within it from containers outside.Read More...'s metadata, as seen in the below example. Simply modify the yaml to suit your deployment and hostname, and apply!

Apply
apiVersion: v1
kind: Service
metadata:
# Name must be the same as in
# the Ambassador mapping below
name: nginx-http
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v1
kind: Mapping
name: nginx-http.namespace
prefix: "/"
service: http://nginx-http.namespace:8080
host: api.stuffbydan.com
timeout_ms: 10000
use_websocket: true
spec:
ports:
- name: tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: nginx
type: ClusterIP
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.apiVersionKube resource version to use
.kindWhat kind of resource is this yaml doc defining
.metadata.nameName of your resource
.specUsed to define how your deployment behaves. Some example properties might be: * selector * minReadySeconds