apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app.kubernetes.io/name: my-test-app
spec:
containers:
- name: nginx
image: nginx
---
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app.kubernetes.io/name: my-test-app
ports:
- protocol: TCP
port: 80
helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx --create-namespace
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.3/cert-manager.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
namespace: default
annotations:
kubernetes.io/ingress.allow-http: "true"
spec:
ingressClassName: nginx
rules:
- host: mytest.l3k.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
% kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
test-ingress nginx mytest.l3k.io 12.123.123.123 80 5m1s
% curl -H "Host: mytest.l3k.io" http://12.123.123.123
…
<h1>Welcome to nginx!</h1>
…
mytest.l3k.io A 12.123.123.123
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: letsencrypt-staging
namespace: default
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory
email: <YOUR_EMAIL> # поменять на ваш имейл
privateKeySecretRef:
name: letsencrypt-staging
solvers:
- http01:
ingress:
ingressClassName: nginx
% curl -v --insecure https://mytest.l3k.io
…
* Server certificate:
* subject: CN=mytest.l3k.io
* start date: Feb 23 11:56:07 2024 GMT
* expire date: May 23 11:56:06 2024 GMT
* issuer: C=US; O=(STAGING) Let's Encrypt; CN=(STAGING) Artificial Apricot R3
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: letsencrypt-production
namespace: default
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: <YOUR_EMAIL>
privateKeySecretRef:
name: letsencrypt-production
solvers:
- http01:
ingress:
ingressClassName: nginx
% diff -u ingress-https-staging.yaml ingress-https-prod.yaml
--- ingress-https-staging.yaml 2024-02-23 15:53:22
+++ ingress-https-prod.yaml 2024-02-23 18:03:02
@@ -5,7 +5,7 @@
namespace: default
annotations:
kubernetes.io/ingress.allow-http: "true"
- cert-manager.io/issuer: letsencrypt-staging
+ cert-manager.io/issuer: letsencrypt-production
acme.cert-manager.io/http01-edit-in-place: "true"
spec:
ingressClassName: nginx
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-namecom
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: <YOUR_EMAIL>
privateKeySecretRef:
name: letsencrypt-account-key
solvers:
- dns01:
webhook:
groupName: acme.name.com
solverName: namedotcom
config:
username: <YOUR_LOGIN>
apitokensecret:
name: namedotcom-credentials
key: api-token
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: l3k-test
spec:
dnsNames:
- '*.l3k.io'
issuerRef:
name: letsencrypt-namecom
kind: ClusterIssuer
secretName: wild-cert
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
namespace: default
annotations:
kubernetes.io/ingress.allow-http: "true"
spec:
ingressClassName: nginx
tls:
- secretName: wild-cert
hosts:
- '*.l3k.io'
rules:
- host: '*.l3k.io'
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80