Last active
May 22, 2017 12:03
-
-
Save noonien/df181576fab290d4008f151f316f7f8c to your computer and use it in GitHub Desktop.
kube-lego + nginx-ingress on k8s 1.6+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: kube-lego |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: kube-lego | |
namespace: kube-lego | |
data: | |
# modify this to specify your address | |
lego.email: "[email protected]" | |
# configure letencrypt's production api | |
# lego.url: "https://acme-v01.api.letsencrypt.org/directory" | |
# configure letencrypt's staging api | |
lego.url: "https://acme-staging.api.letsencrypt.org/directory" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRole | |
metadata: | |
name: lego | |
rules: | |
- apiGroups: | |
- "" | |
- extensions | |
resources: | |
- configmaps | |
- secrets | |
- services | |
- endpoints | |
- ingresses | |
- nodes | |
- pods | |
verbs: | |
- list | |
- get | |
- watch | |
- apiGroups: | |
- extensions | |
- "" | |
resources: | |
- ingresses | |
- ingresses/status | |
verbs: | |
- get | |
- update | |
- create | |
- list | |
- patch | |
- delete | |
- watch | |
- apiGroups: | |
- "*" | |
- "" | |
resources: | |
- events | |
- certificates | |
- secrets | |
verbs: | |
- create | |
- list | |
- update | |
- get | |
- patch | |
- watch | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: lego | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: lego | |
subjects: | |
- kind: ServiceAccount | |
name: lego | |
namespace: kube-lego | |
--- | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: lego | |
namespace: kube-lego |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: kube-lego | |
namespace: kube-lego | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: kube-lego | |
spec: | |
serviceAccountName: lego | |
containers: | |
- name: kube-lego | |
image: jetstack/kube-lego:0.1.4 | |
imagePullPolicy: Always | |
ports: | |
- containerPort: 8080 | |
env: | |
- name: LEGO_EMAIL | |
valueFrom: | |
configMapKeyRef: | |
name: kube-lego | |
key: lego.email | |
- name: LEGO_URL | |
valueFrom: | |
configMapKeyRef: | |
name: kube-lego | |
key: lego.url | |
- name: LEGO_NAMESPACE | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.namespace | |
- name: LEGO_POD_IP | |
valueFrom: | |
fieldRef: | |
fieldPath: status.podIP | |
readinessProbe: | |
httpGet: | |
path: /healthz | |
port: 8080 | |
initialDelaySeconds: 5 | |
timeoutSeconds: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: nginx-ingress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: rbac.authorization.k8s.io/v1alpha1 | |
kind: ClusterRole | |
metadata: | |
name: ingress | |
rules: | |
- apiGroups: | |
- "" | |
- extensions | |
resources: | |
- configmaps | |
- secrets | |
- services | |
- endpoints | |
- ingresses | |
- nodes | |
- pods | |
verbs: | |
- list | |
- watch | |
- apiGroups: | |
- "" | |
resources: | |
- services | |
verbs: | |
- list | |
- watch | |
- get | |
- update | |
- apiGroups: | |
- extensions | |
resources: | |
- ingresses | |
verbs: | |
- get | |
- apiGroups: | |
- "" | |
resources: | |
- events | |
verbs: | |
- create | |
- apiGroups: | |
- extensions | |
resources: | |
- ingresses/status | |
verbs: | |
- update | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1alpha1 | |
kind: Role | |
metadata: | |
name: ingress-ns | |
namespace: nginx-ingress | |
rules: | |
- apiGroups: | |
- "" | |
resources: | |
- pods | |
verbs: | |
- list | |
- apiGroups: | |
- "" | |
resources: | |
- services | |
verbs: | |
- get | |
- apiGroups: | |
- "" | |
resources: | |
- endpoints | |
verbs: | |
- get | |
- create | |
- update | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1alpha1 | |
kind: RoleBinding | |
metadata: | |
name: ingress-ns-binding | |
namespace: nginx-ingress | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: Role | |
name: ingress-ns | |
subjects: | |
- kind: ServiceAccount | |
name: default | |
namespace: nginx-ingress | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1alpha1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: ingress-binding | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: ingress | |
subjects: | |
- kind: ServiceAccount | |
name: default | |
namespace: nginx-ingress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: nginx-ingress-controller | |
labels: | |
k8s-app: nginx-ingress-controller | |
namespace: nginx-ingress | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
k8s-app: nginx-ingress-controller | |
annotations: | |
prometheus.io/port: '10254' | |
prometheus.io/scrape: 'true' | |
spec: | |
# hostNetwork makes it possible to use ipv6 and to preserve the source IP correctly regardless of docker configuration | |
# however, it is not a hard dependency of the nginx-ingress-controller itself and it may cause issues if port 10254 already is taken on the host | |
# that said, since hostPort is broken on CNI (https://github.com/kubernetes/kubernetes/issues/31307) we have to use hostNetwork where CNI is used | |
# like with kubeadm | |
# hostNetwork: true | |
terminationGracePeriodSeconds: 60 | |
containers: | |
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.5 | |
name: nginx-ingress-controller | |
readinessProbe: | |
httpGet: | |
path: /healthz | |
port: 10254 | |
scheme: HTTP | |
livenessProbe: | |
httpGet: | |
path: /healthz | |
port: 10254 | |
scheme: HTTP | |
initialDelaySeconds: 10 | |
timeoutSeconds: 1 | |
ports: | |
- containerPort: 80 | |
hostPort: 80 | |
- containerPort: 443 | |
hostPort: 443 | |
env: | |
- name: POD_NAME | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.name | |
- name: POD_NAMESPACE | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.namespace | |
args: | |
- /nginx-ingress-controller | |
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx | |
namespace: nginx-ingress | |
spec: | |
type: NodePort | |
externalIPs: | |
- public.ip.goes.here | |
ports: | |
- port: 80 | |
name: http | |
- port: 443 | |
name: https | |
selector: | |
app: nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: default-http-backend | |
labels: | |
k8s-app: default-http-backend | |
namespace: nginx-ingress | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
k8s-app: default-http-backend | |
spec: | |
terminationGracePeriodSeconds: 60 | |
containers: | |
- name: default-http-backend | |
# Any image is permissable as long as: | |
# 1. It serves a 404 page at / | |
# 2. It serves 200 on a /healthz endpoint | |
image: gcr.io/google_containers/defaultbackend:1.0 | |
livenessProbe: | |
httpGet: | |
path: /healthz | |
port: 8080 | |
scheme: HTTP | |
initialDelaySeconds: 30 | |
timeoutSeconds: 5 | |
ports: | |
- containerPort: 8080 | |
resources: | |
limits: | |
cpu: 10m | |
memory: 20Mi | |
requests: | |
cpu: 10m | |
memory: 20Mi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: default-http-backend | |
namespace: nginx-ingress | |
labels: | |
k8s-app: default-http-backend | |
spec: | |
ports: | |
- port: 80 | |
targetPort: 8080 | |
selector: | |
k8s-app: default-http-backend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment