Parallel build of bootstrap/upgrade ova;Split ansible tasks respectively
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-01-18 15:09:32 +01:00
parent 8ba8b5aaab
commit c1bff94cd1
52 changed files with 274 additions and 74 deletions

View File

@ -0,0 +1,28 @@
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: {{ _template.name }}
namespace: {{ _template.namespace }}
spec:
generators:
- git:
repoURL: ssh://git@gitea-ssh.gitea.svc.cluster.local/mc/GitOps.Config.git
revision: HEAD
directories:
- path: metacluster-applicationset/*
template:
metadata:
name: {% raw %}'{{ path.basename }}'{% endraw +%}
spec:
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
source:
repoURL: ssh://git@gitea-ssh.gitea.svc.cluster.local/mc/GitOps.Config.git
targetRevision: HEAD
path: {% raw %}'{{ path }}'{% endraw +%}
destination:
server: https://kubernetes.default.svc
namespace: default

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ _template.cluster.secret }}
namespace: argo-cd
labels:
argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
name: {{ _template.cluster.name }}
server: {{ _template.cluster.url }}
config: |
{
"bearerToken": "{{ _template.cluster.token }}",
"tlsClientConfig": {
"insecure": true
}
}

View File

@ -0,0 +1,42 @@
providers:
- name: "kubeadm"
url: "/opt/metacluster/cluster-api/bootstrap-kubeadm/{{ _template.version.base }}/bootstrap-components.yaml"
type: "BootstrapProvider"
- name: "cluster-api"
url: "/opt/metacluster/cluster-api/cluster-api/{{ _template.version.base }}/core-components.yaml"
type: "CoreProvider"
- name: "kubeadm"
url: "/opt/metacluster/cluster-api/control-plane-kubeadm/{{ _template.version.base }}/control-plane-components.yaml"
type: "ControlPlaneProvider"
- name: "vsphere"
url: "/opt/metacluster/cluster-api/infrastructure-vsphere/{{ _template.version.infrastructure_vsphere }}/infrastructure-components.yaml"
type: "InfrastructureProvider"
- name: "in-cluster"
url: "/opt/metacluster/cluster-api/ipam-in-cluster/{{ _template.version.ipam_incluster }}/ipam-components.yaml"
type: "IPAMProvider"
cert-manager:
url: "/opt/metacluster/cluster-api/cert-manager/{{ _template.version.cert_manager }}/cert-manager.yaml"
version: "{{ _template.version.cert_manager }}"
## -- Controller settings -- ##
VSPHERE_SERVER: "{{ _template.hv.fqdn }}"
VSPHERE_TLS_THUMBPRINT: "{{ _template.hv.tlsthumbprint }}"
VSPHERE_USERNAME: "{{ _template.hv.username }}"
VSPHERE_PASSWORD: "{{ _template.hv.password }}"
## -- Required workload cluster default settings -- ##
VSPHERE_DATACENTER: "{{ _template.hv.datacenter }}"
VSPHERE_DATASTORE: "{{ _template.hv.datastore }}"
VSPHERE_STORAGE_POLICY: ""
VSPHERE_NETWORK: "{{ _template.hv.network }}"
VSPHERE_RESOURCE_POOL: "{{ _template.hv.resourcepool }}"
VSPHERE_FOLDER: "{{ _template.hv.folder }}"
VSPHERE_TEMPLATE: "{{ _template.cluster.nodetemplate }}"
VSPHERE_SSH_AUTHORIZED_KEY: "{{ _template.cluster.publickey }}"
KUBERNETES_VERSION: "{{ _template.cluster.version }}"
CONTROL_PLANE_ENDPOINT_IP: "{{ _template.cluster.vip }}"
VIP_NETWORK_INTERFACE: ""
EXP_CLUSTER_RESOURCE_SET: "true"

View File

@ -0,0 +1,10 @@
#!/bin/bash
# Change working directory
pushd {{ _template.service.workingdir }}
# Compress *.tar files
if tar -czf image-tarballs.tgz *.tar --remove-files; then
# Disable systemd unit
systemctl disable {{ _template.service.name }}
fi

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ _template.name }}
namespace: {{ _template.namespace }}
annotations:
{{ _template.annotations }}
labels:
{{ _template.labels }}
data:
{% for kv_pair in _template.data %}
"{{ kv_pair.key }}": |
{{ kv_pair.value | indent(width=4, first=True) }}
{% endfor %}

View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ _template.name }}-{{ _template.uid }}
namespace: {{ _template.namespace }}
labels:
argocd.argoproj.io/secret-type: repository
stringData:
url: ssh://git@gitea-ssh.gitea.svc.cluster.local/mc/GitOps.Config.git
name: {{ _template.name }}
insecure: 'true'
sshPrivateKey: |
{{ _template.privatekey }}

View File

@ -0,0 +1,7 @@
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ _template.name }}
namespace: {{ _template.namespace }}
spec:
{{ _template.config }}

View File

@ -0,0 +1,7 @@
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
name: {{ _template.name }}
namespace: {{ _template.namespace }}
spec:
{{ _template.config }}

View File

@ -0,0 +1,104 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cluster-template.yaml
patchesStrategicMerge:
- |-
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
name: '${CLUSTER_NAME}'
namespace: '${NAMESPACE}'
spec:
kubeadmConfigSpec:
clusterConfiguration:
imageRepository: registry.{{ _template.fqdn }}/kubeadm
- |-
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: '${CLUSTER_NAME}-md-0'
namespace: '${NAMESPACE}'
spec:
template:
spec:
clusterConfiguration:
imageRepository: registry.{{ _template.fqdn }}/kubeadm
- |-
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: '${CLUSTER_NAME}-md-0'
namespace: '${NAMESPACE}'
spec:
template:
spec:
files:
- encoding: base64
content: |
{{ _template.script.encoded }}
permissions: '0744'
owner: root:root
path: /root/network.sh
- content: |
network: {config: disabled}
owner: root:root
path: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
- content: |
{{ _template.rootca | indent(width=14, first=False) | trim }}
owner: root:root
path: /usr/local/share/ca-certificates/root_ca.crt
patchesJson6902:
- target:
group: controlplane.cluster.x-k8s.io
version: v1beta1
kind: KubeadmControlPlane
name: .*
patch: |-
- op: add
path: /spec/kubeadmConfigSpec/files/-
value:
encoding: base64
content: |
{{ _template.script.encoded }}
owner: root:root
path: /root/network.sh
permissions: '0744'
- op: add
path: /spec/kubeadmConfigSpec/files/-
value:
content: |
network: {config: disabled}
owner: root:root
path: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
- op: add
path: /spec/kubeadmConfigSpec/files/-
value:
content: |
{{ _template.rootca | indent(width=12, first=False) | trim }}
owner: root:root
path: /usr/local/share/ca-certificates/root_ca.crt
- target:
group: bootstrap.cluster.x-k8s.io
version: v1beta1
kind: KubeadmConfigTemplate
name: .*
patch: |-
{% for cmd in _template.runcmds %}
- op: add
path: /spec/template/spec/preKubeadmCommands/-
value: {{ cmd }}
{% endfor %}
- target:
group: controlplane.cluster.x-k8s.io
version: v1beta1
kind: KubeadmControlPlane
name: .*
patch: |-
{% for cmd in _template.runcmds %}
- op: add
path: /spec/kubeadmConfigSpec/preKubeadmCommands/-
value: {{ cmd }}
{% endfor %}

View File

@ -0,0 +1,8 @@
mirrors:
{% for entry in _template.data %}
{{ entry }}:
endpoint:
- https://registry.{{ _template.hv.fqdn }}
rewrite:
"(.*)": "library/{{ entry }}/$1"
{% endfor %}

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ _template.name }}
namespace: {{ _template.namespace }}
data:
{% for kv_pair in _template.data %}
"{{ kv_pair.key }}": {{ kv_pair.value }}
{% endfor %}

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ _template.account.name }}
namespace: {{ _template.account.namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ _template.clusterrolebinding.name }}
subjects:
- kind: ServiceAccount
name: {{ _template.account.name }}
namespace: {{ _template.account.namespace }}
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io

View File

@ -0,0 +1,9 @@
[Unit]
Description={{ _template.service.name }}
[Service]
ExecStart={{ _template.service.executable }}
Nice=10
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,47 @@
#!/bin/bash
export TERM=linux
BGRN='\033[1;92m'
BGRY='\033[1;30m'
BBLU='\033[1;34m'
BRED='\033[1;91m'
BWHI='\033[1;97m'
CBLA='\033[?16;0;30c' # Hide blinking cursor
DFLT='\033[0m' # Reset colour
LCLR='\033[K' # Clear to end of line
PRST='\033[0;0H' # Reset cursor position
# COMPONENTS=('ca' 'ingress' 'storage' 'registry' 'git' 'gitops')
COMPONENTS=('ca' 'storage' 'registry' 'git' 'gitops')
FQDN='{{ vapp['metacluster.fqdn'] }}'
IPADDRESS='{{ vapp['guestinfo.ipaddress'] }}'
I=60
while /bin/true; do
if [[ $I -gt 59 ]]; then
clear > /dev/tty1
I=0
else
I=$(( $I + 1 ))
fi
echo -e "${PRST}" > /dev/tty1
echo -e "\n\n\t${DFLT}To manage this appliance, please connect to one of the following:${LCLR}\n" > /dev/tty1
for c in "${COMPONENTS[@]}"; do
STATUS=$(curl -ks "https://${c}.${FQDN}" -o /dev/null -w '%{http_code}')
if [[ "${STATUS}" -eq "200" ]]; then
echo -e "\t [${BGRN}+${DFLT}] ${BBLU}https://${c}.${FQDN}${DFLT}${LCLR}" > /dev/tty1
else
echo -e "\t [${BRED}-${DFLT}] ${BBLU}https://${c}.${FQDN}${DFLT}${LCLR}" > /dev/tty1
fi
done
echo -e "\n\t${BGRY}Note that your DNS zone ${DFLT}must have${BGRY} respective records defined,\n\teach pointing to: ${DFLT}${IPADDRESS}${LCLR}" > /dev/tty1
echo -e "${CBLA}" > /dev/tty1
sleep 1
done