Skip to content

Commit 35156c7

Browse files
authored
Merge pull request #76 from cliveseldon/ansible
Add ansible playbooks
2 parents d4e8c5b + 7b97843 commit 35156c7

File tree

46 files changed

+901
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+901
-18
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ examples/*.h5
111111

112112
# emacs
113113
*~
114+
.\#*
114115

115116
# Test models
116117
tests/testdata/keras

Makefile

+14-5
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,28 @@ test:
1616

1717
.PHONY: fmt
1818
fmt:
19-
isort .
19+
isort . \
20+
--skip ansible \
21+
--skip .tox \
22+
--skip .eggs \
23+
--skip build
2024
black . \
21-
--exclude "(.eggs|.tox)" \
25+
--exclude "(.eggs|.tox|ansible|build)" \
2226
--line-length 120
2327

2428
.PHONY: lint
2529
lint:
26-
flake8 .
30+
flake8 . \
31+
--extend-exclude "ansible"
2732
mypy ./tempo
28-
isort . --check
33+
isort . --check \
34+
--skip ansible \
35+
--skip .tox \
36+
--skip .eggs \
37+
--skip build
2938
black . \
3039
--check \
31-
--exclude "(.eggs|.tox)" \
40+
--exclude "(.eggs|.tox|ansible|build)" \
3241
--line-length 120
3342

3443
.PHONY: install-rclone

ansible/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.resources

ansible/Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
KIND_IMAGE ?= kindest/node:v1.18.15
2+
KIND_NAME ?= ansible
3+
4+
5+
# Kind Cluster
6+
kind-cluster:
7+
kind create cluster --name ${KIND_NAME} --image ${KIND_IMAGE} || echo "already there"
8+
kind export kubeconfig --name ${KIND_NAME}
9+
kubectl create ns seldon || echo "already there"
10+
kubectl config set-context --current --namespace seldon
11+
12+
13+
kind-delete:
14+
kind delete cluster --name ${KIND_NAME}
15+
16+
17+
18+
# Port Forwards
19+
port-forward-ambassador:
20+
kubectl port-forward -n ambassador svc/ambassador 8003:80
21+
22+
port-forward-istio:
23+
kubectl port-forward -n istio-system svc/istio-ingressgateway 8003:80
24+
25+
port-forward-istio-8004:
26+
kubectl port-forward -n istio-system svc/istio-ingressgateway 8004:80
27+
28+
port-forward-minio:
29+
kubectl port-forward -n minio-system svc/minio 8090:9000

ansible/ansible-tools/inventory.ini

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[all:vars]
2+
ansible_python_interpreter=python3
3+
4+
[all]
5+
localhost ansible_connection=local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
ambassador_namespace: ambassador
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: "Create a k8s namespace: {{ ambassador_namespace }}"
3+
community.kubernetes.k8s:
4+
name: "{{ ambassador_namespace }}"
5+
api_version: v1
6+
kind: Namespace
7+
state: present
8+
9+
- name: Install ambassador
10+
community.kubernetes.helm:
11+
name: ambassador
12+
release_namespace: "{{ ambassador_namespace }}"
13+
chart_repo_url: "https://www.getambassador.io"
14+
chart_ref: "ambassador"
15+
values:
16+
image:
17+
repository: quay.io/datawire/ambassador
18+
enableAES: false
19+
crds.keep: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
argo_namespace: argo
3+
argo_version: null # means that --version is not set so latest is used
4+
5+
argo_wait_for_deployments: false
6+
argo_configure_rbac: true
7+
8+
argo_values: {}
9+
argo_values_files: []
10+
11+
workflow_namespaces: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
#### Install
4+
5+
- name: "Create a k8s namespaces: {{ argo_namespace }}"
6+
community.kubernetes.k8s:
7+
name: "{{ argo_namespace }}"
8+
api_version: v1
9+
kind: Namespace
10+
state: present
11+
12+
- name: Install Argo Workflows
13+
community.kubernetes.helm:
14+
name: argo
15+
release_namespace: "{{ argo_namespace }}"
16+
chart_repo_url: "https://argoproj.github.io/argo-helm"
17+
chart_ref: "argo"
18+
chart_version: "{{ argo_version }}"
19+
values: "{{ argo_values }}"
20+
values_files: "{{ argo_values_files }}"
21+
22+
- name: Wait for Argo deployments
23+
community.kubernetes.k8s_info:
24+
kind: Deployment
25+
wait: yes
26+
wait_condition:
27+
type: Available
28+
status: "True"
29+
reason: MinimumReplicasAvailable
30+
name: "{{ item }}"
31+
namespace: "{{ argo_namespace }}"
32+
wait_timeout: 360
33+
with_items:
34+
- argo-server
35+
- workflow-controller
36+
when: argo_wait_for_deployments | bool
37+
38+
- name: Configure Service RBAC
39+
include: rbac.yaml
40+
when: argo_configure_rbac | bool
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
- name: Create Workflow Role
3+
community.kubernetes.k8s:
4+
state: present
5+
name: workflow
6+
namespace: "{{ loop_namespace }}"
7+
definition:
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: Role
10+
metadata:
11+
name: workflow
12+
rules:
13+
- apiGroups:
14+
- ""
15+
resources:
16+
- pods
17+
verbs:
18+
- "*"
19+
- apiGroups:
20+
- "apps"
21+
resources:
22+
- deployments
23+
verbs:
24+
- "*"
25+
- apiGroups:
26+
- ""
27+
resources:
28+
- pods/log
29+
verbs:
30+
- "*"
31+
- apiGroups:
32+
- machinelearning.seldon.io
33+
resources:
34+
- "*"
35+
verbs:
36+
- "*"
37+
loop: "{{ workflow_namespaces }}"
38+
loop_control:
39+
loop_var: loop_namespace
40+
41+
- name: Create Workflow Role
42+
community.kubernetes.k8s:
43+
state: present
44+
name: workflow
45+
namespace: "{{ loop_namespace }}"
46+
definition:
47+
apiVersion: v1
48+
kind: ServiceAccount
49+
metadata:
50+
name: workflow
51+
loop: "{{ workflow_namespaces }}"
52+
loop_control:
53+
loop_var: loop_namespace
54+
55+
- name: Create Rolebinding
56+
community.kubernetes.k8s:
57+
state: present
58+
name: workflow
59+
namespace: "{{ loop_namespace }}"
60+
definition:
61+
apiVersion: rbac.authorization.k8s.io/v1
62+
kind: RoleBinding
63+
metadata:
64+
name: workflow
65+
subjects:
66+
- kind: ServiceAccount
67+
name: workflow
68+
namespace: "{{ loop_namespace }}"
69+
roleRef:
70+
apiGroup: rbac.authorization.k8s.io
71+
kind: Role
72+
name: workflow
73+
loop: "{{ workflow_namespaces }}"
74+
loop_control:
75+
loop_var: loop_namespace
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
argocd_namespace: argocd
3+
argocd_version: v1.7.10
4+
argocd_manifest: https://raw.githubusercontent.com/argoproj/argo-cd/{{ argocd_version }}/manifests/install.yaml
5+
6+
gitops_repository: ""
7+
gitops_namespaces: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
- name: "Create a k8s namespaces: {{ argocd_namespace }}"
3+
community.kubernetes.k8s:
4+
name: "{{ argocd_namespace }}"
5+
api_version: v1
6+
kind: Namespace
7+
state: present
8+
9+
- name: Deploy ArgoCD
10+
community.kubernetes.k8s:
11+
state: present
12+
namespace: "{{ argocd_namespace }}"
13+
definition: "{{ lookup('url', argocd_manifest, split_lines=False) }}"
14+
15+
- name: Wait for ArgoCD deployments
16+
community.kubernetes.k8s_info:
17+
kind: Deployment
18+
wait: yes
19+
wait_condition:
20+
type: Available
21+
status: "True"
22+
reason: MinimumReplicasAvailable
23+
name: "{{ item }}"
24+
namespace: "{{ argocd_namespace }}"
25+
wait_timeout: 360
26+
with_items:
27+
- argocd-application-controller
28+
- argocd-repo-server
29+
- argocd-server
30+
- argocd-redis
31+
- argocd-dex-server
32+
33+
- name: Create a k8s namespaces
34+
community.kubernetes.k8s:
35+
name: "{{ item }}"
36+
api_version: v1
37+
kind: Namespace
38+
state: present
39+
with_items: "{{ gitops_namespaces }}"
40+
41+
- name: Configure ArgoCD Project
42+
community.kubernetes.k8s:
43+
state: present
44+
template: templates/project.j2
45+
46+
- name: Configure ArgoCD Applications
47+
community.kubernetes.k8s:
48+
state: present
49+
template: templates/application.j2
50+
loop: "{{ gitops_namespaces }}"
51+
loop_control:
52+
loop_var: loop_namespace
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: seldon-gitops-{{ loop_namespace }}
5+
namespace: argocd
6+
spec:
7+
project: seldon
8+
destination:
9+
namespace: {{ loop_namespace }}
10+
server: https://kubernetes.default.svc
11+
source:
12+
repoURL: {{ gitops_repository }}
13+
path: {{ loop_namespace }}
14+
directory:
15+
recurse: true
16+
syncPolicy:
17+
automated:
18+
prune: true
19+
selfHeal: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: AppProject
3+
metadata:
4+
name: seldon
5+
namespace: {{ argocd_namespace }}
6+
spec:
7+
description: Seldon Gitops Project
8+
sourceRepos:
9+
- {{ gitops_repository }}
10+
destinations:
11+
{% for namespace in gitops_namespaces %}
12+
- namespace: {{ namespace }}
13+
server: https://kubernetes.default.svc
14+
{% endfor %}
15+
clusterResourceWhitelist:
16+
- group: '*'
17+
kind: '*'
18+
roles:
19+
- name: seldon-admin
20+
policies:
21+
- p, proj:seldon:seldon-admin, applications, get, seldon/*, allow
22+
- p, proj:seldon:seldon-admin, applications, create, seldon/*, allow
23+
- p, proj:seldon:seldon-admin, applications, update, seldon/*, allow
24+
- p, proj:seldon:seldon-admin, applications, delete, seldon/*, allow
25+
- p, proj:seldon:seldon-admin, applications, sync, seldon/*, allow
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
certmanager_version: v1.0.4
3+
certmanager_yaml: "https://github.com/jetstack/cert-manager/releases/download/{{ certmanager_version }}/cert-manager.yaml"
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Install Certmanager
3+
community.kubernetes.k8s:
4+
state: present
5+
definition: "{{ lookup('url', item, split_lines=False) }}"
6+
with_items:
7+
- "{{ certmanager_yaml }}"
8+
9+
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
istio_version: 1.7.6
3+
istio_verify_install: true

0 commit comments

Comments
 (0)