Update for a fonctionnal deployment
This commit is contained in:
parent
9fa90d889e
commit
206f44c362
16 changed files with 90 additions and 22 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
context: "{{ my_context }}"
|
context: "{{ my_context }}"
|
||||||
name: tools
|
name: traefik
|
||||||
api_version: v1
|
api_version: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: basic-auth
|
name: basic-auth
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
type: Opaque
|
type: Opaque
|
||||||
data:
|
data:
|
||||||
basic_auth: "{{ basic_auth_data | b64encode }}"
|
basic_auth: "{{ basic_auth_data | b64encode }}"
|
||||||
|
|
@ -28,22 +28,39 @@
|
||||||
- basic_auth == true
|
- basic_auth == true
|
||||||
tags: traefik
|
tags: traefik
|
||||||
|
|
||||||
|
- name: Add host label for traefik deployment
|
||||||
|
k8s:
|
||||||
|
state: present
|
||||||
|
context: "{{ my_context }}"
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Node
|
||||||
|
metadata:
|
||||||
|
name: "{{ item }}"
|
||||||
|
labels:
|
||||||
|
entrypoint: traefik
|
||||||
|
with_items:
|
||||||
|
- '{{ traefik_node_selector }}'
|
||||||
|
when:
|
||||||
|
- traefik_node_selector is defined
|
||||||
|
tags: traefik
|
||||||
|
|
||||||
- name: Get Deployment information object
|
- name: Get Deployment information object
|
||||||
k8s_facts:
|
k8s_facts:
|
||||||
context: "{{ my_context }}"
|
context: "{{ my_context }}"
|
||||||
api_version: v1
|
api_version: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: traefik
|
name: traefik
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
field_selectors:
|
field_selectors:
|
||||||
- spec.template.spec.containers.image
|
- spec.template.spec.containers.image
|
||||||
register: traefik_actual_resources
|
register: traefik_actual_resources
|
||||||
|
|
||||||
- name: Retreive actual traefik version
|
- name: Retreive actual traefik version
|
||||||
shell: echo "{{ traefik_actual_resources.resources }}" | sed "s/.*traefik:v\([.0-9]*\).*/\1/" | uniq
|
shell: echo "{{ traefik_actual_resources.resources }}" | sed "s/.*traefik:\([.0-9]*\).*/\1/" | uniq
|
||||||
register: traefik_actual_version
|
register: traefik_actual_version
|
||||||
|
|
||||||
- name: install / uninstall version 2.0
|
- name: install / uninstall version 2.0
|
||||||
include_tasks: "version_2.0.yml"
|
include_tasks: "version_2.0.yml"
|
||||||
when:
|
when:
|
||||||
- traefik_version == 2.0 or traefik_actual_version.stdout == 2.0
|
- traefik_version == "2.0" or traefik_actual_version.stdout == "2.0"
|
||||||
|
|
|
||||||
49
tasks/main.yml.old
Normal file
49
tasks/main.yml.old
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#- debug: var=my_context
|
||||||
|
# tags: traefik
|
||||||
|
|
||||||
|
- name: traefik setup
|
||||||
|
block:
|
||||||
|
- name: namespace
|
||||||
|
k8s:
|
||||||
|
state: present
|
||||||
|
context: "{{ my_context }}"
|
||||||
|
name: tools
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
|
||||||
|
- name: Create a Secret object for basic authentification
|
||||||
|
k8s:
|
||||||
|
state: present
|
||||||
|
context: "{{ my_context }}"
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: basic-auth
|
||||||
|
namespace: tools
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
basic_auth: "{{ basic_auth_data | b64encode }}"
|
||||||
|
when:
|
||||||
|
- basic_auth == true
|
||||||
|
tags: traefik
|
||||||
|
|
||||||
|
- name: Get Deployment information object
|
||||||
|
k8s_facts:
|
||||||
|
context: "{{ my_context }}"
|
||||||
|
api_version: v1
|
||||||
|
kind: Deployment
|
||||||
|
name: traefik
|
||||||
|
namespace: tools
|
||||||
|
field_selectors:
|
||||||
|
- spec.template.spec.containers.image
|
||||||
|
register: traefik_actual_resources
|
||||||
|
|
||||||
|
- name: Retreive actual traefik version
|
||||||
|
shell: echo "{{ traefik_actual_resources.resources }}" | sed "s/.*traefik:v\([.0-9]*\).*/\1/" | uniq
|
||||||
|
register: traefik_actual_version
|
||||||
|
|
||||||
|
- name: install / uninstall version 2.0
|
||||||
|
include_tasks: "version_2.0.yml"
|
||||||
|
when:
|
||||||
|
- traefik_version == 2.0 or traefik_actual_version.stdout == 2.0
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
when:
|
when:
|
||||||
- traefik_version != "2.0"
|
- traefik_version != "2.0"
|
||||||
|
|
||||||
- name: traefik files
|
- name: traefik files version {{ traefik_version }} need to be {{ traefik_2_0_state }}
|
||||||
k8s:
|
k8s:
|
||||||
state: "{{ traefik_2_0_state }}"
|
state: "{{ traefik_2_0_state }}"
|
||||||
context: "{{ my_context }}"
|
context: "{{ my_context }}"
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ roleRef:
|
||||||
subjects:
|
subjects:
|
||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: traefik-ingress-controller
|
name: traefik-ingress-controller
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,4 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
name: traefik
|
name: traefik
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: ingressroutes.traefik.containo.us
|
name: ingressroutes.traefik.containo.us
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: ingressroutetcps.traefik.containo.us
|
name: ingressroutetcps.traefik.containo.us
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: middlewares.traefik.containo.us
|
name: middlewares.traefik.containo.us
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: traefik-dashboard-insecure
|
name: traefik-dashboard-insecure
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
name: traefik-dashboard
|
name: traefik-dashboard
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
ports:
|
ports:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: traefik-dashboard
|
name: traefik-dashboard
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
metadata:
|
metadata:
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
name: traefik
|
name: traefik
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: {% if traefik_node_selector is defined %}{{ traefik_node_selector|length }}{% else %}1{% endif %}
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
|
@ -27,15 +27,15 @@ spec:
|
||||||
- name: http
|
- name: http
|
||||||
containerPort: 80
|
containerPort: 80
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
# hostPort: 80
|
hostPort: 80
|
||||||
- name: https
|
- name: https
|
||||||
containerPort: 443
|
containerPort: 443
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
# hostPort: 443
|
hostPort: 443
|
||||||
- name: traefik
|
- name: traefik
|
||||||
containerPort: 8080
|
containerPort: 8080
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
# hostPort: 8080
|
hostPort: 8080
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /ping
|
path: /ping
|
||||||
|
|
@ -66,7 +66,7 @@ spec:
|
||||||
name: config
|
name: config
|
||||||
{% if traefik_node_selector is defined %}
|
{% if traefik_node_selector is defined %}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: "{% for node_selector in traefik_node_selector %}{{ node_selector }}{% if not loop.last %}, {% endif %}{% endfor %}"
|
entrypoint: traefik
|
||||||
{% endif %}
|
{% endif %}
|
||||||
dnsPolicy: ClusterFirst
|
dnsPolicy: ClusterFirst
|
||||||
hostNetwork: false
|
hostNetwork: false
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
||||||
kind: Middleware
|
kind: Middleware
|
||||||
metadata:
|
metadata:
|
||||||
name: basic-auth
|
name: basic-auth
|
||||||
|
namespace: traefik
|
||||||
spec:
|
spec:
|
||||||
basicAuth:
|
basicAuth:
|
||||||
secret: basic-auth
|
secret: basic-auth
|
||||||
|
|
@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
||||||
kind: Middleware
|
kind: Middleware
|
||||||
metadata:
|
metadata:
|
||||||
name: https-only
|
name: https-only
|
||||||
|
namespace: traefik
|
||||||
spec:
|
spec:
|
||||||
redirectScheme:
|
redirectScheme:
|
||||||
scheme: https
|
scheme: https
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ServiceAccount
|
kind: ServiceAccount
|
||||||
metadata:
|
metadata:
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
name: traefik-ingress-controller
|
name: traefik-ingress-controller
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app: traefik
|
app: traefik
|
||||||
name: traefik
|
name: traefik
|
||||||
namespace: tools
|
namespace: traefik
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
ports:
|
ports:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue