Now that you have created your Kubernetes infrastructure and deployed your services to it, you can make them public using a routing profile:
First navigate to your
infra folder and create a new directory called
$ cd infra$ mkdir routing$ cd routing
Create a file named
cert.yaml with the following content:
apiVersion: certmanager.k8s.io/v1alpha1kind: Certificatemetadata:name: my-app-certificatespec:secretName: my-app-certificatednsNames:- newsite.example.comacme:config:- http01:ingressClass: nginxdomains:- newsite.example.comissuerRef:name: letsencrypt-productionkind: ClusterIssuer
Be sure to replace
my-app-certificate with a more appropriate name and
newsite.example.com with a domain that you have configured to be used with your cluster.
Now create a file named
routing.yaml with the following content:
apiVersion: extensions/v1beta1kind: Ingressmetadata:name: my-app-routingnamespace: applicationsannotations:kubernetes.io/ingress.class: "nginx"certmanager.k8s.io/cluster-issuer: letsencrypt-productionspec:tls:- hosts:- newsite.example.comsecretName: my-app-certificaterules:- host: newsite.example.comhttp:paths:- path: /api/commercebackend:serviceName: service-commerceservicePort: 4003- path: /backend:serviceName: frontendservicePort: 80
newsite.example.com with your own values.
spec.rules section, you can specify routing information for each domain name that you want. In this example:
frontend service on port
service-commerce service on port
After you have done setting the values, run the the following command to apply your changes (make sure you are still in
$ kubectl apply -f ./
Your domain will be configured and after a few minutes an SSL certificate will be issued using The LetsEncrypt service.