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:
|
||||
state: present
|
||||
context: "{{ my_context }}"
|
||||
name: tools
|
||||
name: traefik
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
kind: Secret
|
||||
metadata:
|
||||
name: basic-auth
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
type: Opaque
|
||||
data:
|
||||
basic_auth: "{{ basic_auth_data | b64encode }}"
|
||||
|
|
@ -28,22 +28,39 @@
|
|||
- basic_auth == true
|
||||
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
|
||||
k8s_facts:
|
||||
context: "{{ my_context }}"
|
||||
api_version: v1
|
||||
kind: Deployment
|
||||
name: traefik
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
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
|
||||
shell: echo "{{ traefik_actual_resources.resources }}" | sed "s/.*traefik:\([.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
|
||||
- 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:
|
||||
- traefik_version != "2.0"
|
||||
|
||||
- name: traefik files
|
||||
- name: traefik files version {{ traefik_version }} need to be {{ traefik_2_0_state }}
|
||||
k8s:
|
||||
state: "{{ traefik_2_0_state }}"
|
||||
context: "{{ my_context }}"
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ roleRef:
|
|||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: traefik-ingress-controller
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
|
|
|
|||
|
|
@ -45,4 +45,4 @@ metadata:
|
|||
labels:
|
||||
app: traefik
|
||||
name: traefik
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
|
|||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: ingressroutes.traefik.containo.us
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
labels:
|
||||
app: traefik
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
|
|||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: ingressroutetcps.traefik.containo.us
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
labels:
|
||||
app: traefik
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
|
|||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: middlewares.traefik.containo.us
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
labels:
|
||||
app: traefik
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
|||
kind: IngressRoute
|
||||
metadata:
|
||||
name: traefik-dashboard-insecure
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
labels:
|
||||
app: traefik
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ metadata:
|
|||
labels:
|
||||
app: traefik
|
||||
name: traefik-dashboard
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
|
||||
spec:
|
||||
ports:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
|||
kind: IngressRoute
|
||||
metadata:
|
||||
name: traefik-dashboard
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
labels:
|
||||
app: traefik
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
name: traefik
|
||||
labels:
|
||||
app: traefik
|
||||
|
||||
spec:
|
||||
replicas: 1
|
||||
replicas: {% if traefik_node_selector is defined %}{{ traefik_node_selector|length }}{% else %}1{% endif %}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: traefik
|
||||
|
|
@ -27,15 +27,15 @@ spec:
|
|||
- name: http
|
||||
containerPort: 80
|
||||
protocol: TCP
|
||||
# hostPort: 80
|
||||
hostPort: 80
|
||||
- name: https
|
||||
containerPort: 443
|
||||
protocol: TCP
|
||||
# hostPort: 443
|
||||
hostPort: 443
|
||||
- name: traefik
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
# hostPort: 8080
|
||||
hostPort: 8080
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /ping
|
||||
|
|
@ -66,7 +66,7 @@ spec:
|
|||
name: config
|
||||
{% if traefik_node_selector is defined %}
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: "{% for node_selector in traefik_node_selector %}{{ node_selector }}{% if not loop.last %}, {% endif %}{% endfor %}"
|
||||
entrypoint: traefik
|
||||
{% endif %}
|
||||
dnsPolicy: ClusterFirst
|
||||
hostNetwork: false
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
|||
kind: Middleware
|
||||
metadata:
|
||||
name: basic-auth
|
||||
namespace: traefik
|
||||
spec:
|
||||
basicAuth:
|
||||
secret: basic-auth
|
||||
|
|
@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
|
|||
kind: Middleware
|
||||
metadata:
|
||||
name: https-only
|
||||
namespace: traefik
|
||||
spec:
|
||||
redirectScheme:
|
||||
scheme: https
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
name: traefik-ingress-controller
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ metadata:
|
|||
labels:
|
||||
app: traefik
|
||||
name: traefik
|
||||
namespace: tools
|
||||
namespace: traefik
|
||||
|
||||
spec:
|
||||
ports:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue