Skip to main content

Deploy an application and expose it

This page tells you how to deploy a sample web application on an SD cluster and make it available at a public address, with HTTPS.

The application is an NGINX web server. The page uses the components that the SD Ingress module installs:

  • The ingress controller (HAProxy or NGINX) receives the HTTP and HTTPS traffic and sends it to the application.
  • cert-manager gets a TLS certificate for the address of the application.
note

Deploy your applications with your usual tools, for example kubectl, Helm or a GitOps tool. The plugins of furyctl are for the components of the cluster, not for applications.

Prerequisites​

  • An SD cluster with the Ingress module, and a kubectl context for it.
  • A DNS name for the application, for example hello.example.com. The DNS record must point to the load balancer in front of the ingress controller, or to the nodes that run it.
  • If cert-manager gets the certificates: the DNS name must resolve on the internet, and the ingress controller must accept connections from the internet on port 80. Let's Encrypt uses this port to validate the name.

Step 1 - Find the ingress class​

Each ingress controller has an ingress class. The Ingress resource of the application selects the controller with this class.

kubectl get ingressclass

The classes depend on the controller and on its type in furyctl.yaml:

Controllersingle typedual type
HAProxyhaproxyhaproxy-external and haproxy-internal
NGINXnginxexternal and internal

With the dual type, use the external class for the applications of your users. The internal class is for the tools of the operators, for example Grafana.

This page uses the haproxy class. If your class is different, change ingressClassName in Step 3.

Step 2 - Find how the cluster gets the TLS certificates​

Read the tls.provider field of your ingress controller in furyctl.yaml: .spec.distribution.modules.ingress.haproxy.tls.provider or .spec.distribution.modules.ingress.nginx.tls.provider.

  • certManager: cert-manager gets a certificate for each Ingress that has the cert-manager.io/cluster-issuer annotation. The name of the issuer is in .spec.distribution.modules.ingress.certManager.clusterIssuer.name, for example letsencrypt-fury.
  • secret: the ingress controller uses the certificate of furyctl.yaml for all the Ingresses. This certificate must be valid for the DNS name of the application. In Step 3, remove the annotation and the secretName field.
  • none: the ingress controller does not use TLS. In Step 3, remove the annotation and the tls section.

Step 3 - Write the manifests​

Write the manifests in a file, for example hello.yaml. Replace hello.example.com with your DNS name, and letsencrypt-fury with the name of your issuer.

hello.yaml
apiVersion: v1
kind: Namespace
metadata:
name: hello
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
namespace: hello
spec:
replicas: 2
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: nginx
# This image runs NGINX as a non-root user, on port 8080
image: nginxinc/nginx-unprivileged:1.27-alpine
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /
port: http
livenessProbe:
httpGet:
path: /
port: http
resources:
requests:
cpu: 10m
memory: 16Mi
limits:
cpu: 100m
memory: 64Mi
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefault
---
apiVersion: v1
kind: Service
metadata:
name: hello
namespace: hello
spec:
selector:
app: hello
ports:
- name: http
port: 80
targetPort: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello
namespace: hello
annotations:
cert-manager.io/cluster-issuer: letsencrypt-fury
spec:
ingressClassName: haproxy
tls:
- hosts:
- hello.example.com
secretName: hello-tls
rules:
- host: hello.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello
port:
name: http

The Deployment obeys the default rules of the SD Policy module: it has probes, resource limits, an image tag that is not latest, and it runs as a non-root user. If a rule of the cluster blocks the Deployment, the error message names the rule. For more information, see Policy.

tip

To show the application in Forecastle, the dashboard of the cluster, add the forecastle.stakater.com/expose: "true" annotation to the Ingress.

Step 4 - Deploy the application​

kubectl apply -f hello.yaml

Make sure that the Pods are ready:

kubectl -n hello get pods

If cert-manager gets the certificate, make sure that the certificate is ready. This step can take some minutes:

kubectl -n hello get certificate hello-tls

The READY column shows True. If it shows False, read the events of the certificate request with kubectl -n hello describe certificaterequest.

Step 5 - Open the application​

curl https://hello.example.com

The command prints the welcome page of NGINX. You can also open the address in a web browser.

Clean up​

Delete the application:

kubectl delete -f hello.yaml

If the cluster protects the namespaces against deletion, the error message tells you how to remove the protection.

Where to go next​