To create a tls secret that can be used in ingress definitions, we use the following command:
kubectl create secret tls <secret-name> --key <ssl.key> --cert <ssl.crt>
The first parameter is tls to set the secret type, and then the key value and the actual certificate value. These files are usually obtained from your certificate registrar.
If you want to generate your own secret, you can run the following command:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/ssl.key -out /tmp/ssl.crt -subj "/CN=foo.bar.com"