├── helm ├── reloader-values.yaml ├── trust-manager-values.yaml ├── cert-manager-values.yaml ├── argocd-values.yaml └── cilium-values.yaml ├── assets └── wheezy_logo.png ├── hack ├── check_linstor.sh ├── build_talos_image.sh ├── configure_linstor.sh ├── linstor-restore.sh ├── linstor-snapshot-manager.sh └── linstor-backup.sh ├── .gitignore ├── outputs.tf ├── .github └── workflows │ └── terraform-init.yml ├── renovate.json ├── trust-manager.tf ├── providers.tf ├── reloader.tf ├── cilium.tf ├── cert-manager.tf ├── argocd.tf ├── variables.tf ├── proxmox.tf ├── Readme.md ├── talos.tf └── LICENSE /helm/reloader-values.yaml: -------------------------------------------------------------------------------- 1 | reloader: 2 | autoReloadAll: false 3 | -------------------------------------------------------------------------------- /helm/trust-manager-values.yaml: -------------------------------------------------------------------------------- 1 | secretTargets: 2 | enabled: true 3 | authorizedSecretsAll: true 4 | -------------------------------------------------------------------------------- /assets/wheezy_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florianspk/home-lab-talos/HEAD/assets/wheezy_logo.png -------------------------------------------------------------------------------- /hack/check_linstor.sh: -------------------------------------------------------------------------------- 1 | kubectl linstor node list 2 | kubectl linstor storage-pool list 3 | kubectl linstor volume list -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform/ 2 | terraform.tfvars 3 | *.tfstate* 4 | tfplan 5 | *.log 6 | *.raw 7 | *.qcow2 8 | *.gz 9 | *.tfvars 10 | tmp 11 | .terraform.lock.hcl 12 | .env -------------------------------------------------------------------------------- /helm/cert-manager-values.yaml: -------------------------------------------------------------------------------- 1 | installCRDs: true 2 | 3 | config: 4 | enableGatewayAPI: true 5 | kind: ControllerConfiguration 6 | apiVersion: "controller.config.cert-manager.io/v1alpha1" 7 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | output "talosconfig" { 2 | value = data.talos_client_configuration.talos.talos_config 3 | sensitive = true 4 | } 5 | 6 | output "kubeconfig" { 7 | value = talos_cluster_kubeconfig.talos.kubeconfig_raw 8 | sensitive = true 9 | } 10 | 11 | output "controllers" { 12 | value = join(",", [for node in local.controller_nodes : node.address]) 13 | } 14 | 15 | output "workers" { 16 | value = join(",", [for node in local.worker_nodes : node.address]) 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/terraform-init.yml: -------------------------------------------------------------------------------- 1 | name: Terraform Init 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | terraform-init: 11 | name: Run Terraform Init 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v6 17 | 18 | - name: Setup Terraform 19 | uses: hashicorp/setup-terraform@v3 20 | with: 21 | terraform_version: 1.10.3 22 | 23 | - name: Terraform Init 24 | run: terraform init 25 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "regexManagers": [ 4 | { 5 | "fileMatch": [ 6 | ".yml$", 7 | ".hcl$", 8 | ".tf$", 9 | ".sh$", 10 | ".md$" 11 | ], 12 | "matchStrings": [ 13 | "# renovate: datasource=(?[^:]+?) depName=(?.+?)( versioning=(?.+?))?( extractVersion=(?.+?))?( registryUrl=(?.+?))?\\s.+?[:=]\\s*[\"']?(?.+?)[\"']?\\s" 14 | ], 15 | "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver-coerced{{/if}}", 16 | "extractVersionTemplate": "{{#if extractVersion}}{{{extractVersion}}}{{else}}^v?(?.+)${{/if}}" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /trust-manager.tf: -------------------------------------------------------------------------------- 1 | # install trust-manager. 2 | # NB the default values are described at: 3 | # https://github.com/cert-manager/trust-manager/blob/v0.14.0/deploy/charts/trust-manager/values.yaml 4 | # NB make sure you are seeing the same version of the chart that you are installing. 5 | # see https://cert-manager.io/docs/tutorials/getting-started-with-trust-manager/ 6 | # see https://github.com/cert-manager/trust-manager 7 | # see https://github.com/golang/go/blob/go1.22.3/src/crypto/x509/root_linux.go 8 | # see https://artifacthub.io/packages/helm/cert-manager/trust-manager 9 | # see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template 10 | data "helm_template" "trust_manager" { 11 | namespace = "cert-manager" 12 | name = "trust-manager" 13 | repository = "https://charts.jetstack.io" 14 | chart = "trust-manager" 15 | # renovate: datasource=helm depName=trust-manager registryUrl=https://charts.jetstack.io 16 | version = "0.20.3" 17 | kube_version = var.kubernetes_version 18 | api_versions = [] 19 | values = [file("${path.module}/helm/trust-manager-values.yaml")] 20 | } 21 | -------------------------------------------------------------------------------- /providers.tf: -------------------------------------------------------------------------------- 1 | # see https://github.com/hashicorp/terraform 2 | terraform { 3 | required_version = ">1.10.0" 4 | required_providers { 5 | random = { 6 | source = "hashicorp/random" 7 | version = "3.7.2" 8 | } 9 | cloudinit = { 10 | source = "hashicorp/cloudinit" 11 | version = "2.3.7" 12 | } 13 | proxmox = { 14 | source = "bpg/proxmox" 15 | version = "0.89.1" 16 | } 17 | talos = { 18 | source = "siderolabs/talos" 19 | version = "0.9.0" 20 | } 21 | helm = { 22 | source = "hashicorp/helm" 23 | version = "3.1.1" 24 | } 25 | kustomizer = { 26 | source = "rgl/kustomizer" 27 | version = "0.0.3" 28 | } 29 | } 30 | } 31 | 32 | provider "proxmox" { 33 | tmp_dir = "tmp" 34 | endpoint = "https://${var.proxmox_pve_node_name[0]}.${var.pve_domain}:8006" 35 | api_token = var.api_token 36 | ssh { 37 | agent = true 38 | username = "root" 39 | private_key = file("${var.path_private_key}") 40 | dynamic "node" { 41 | for_each = var.proxmox_pve_node_name 42 | content { 43 | name = node.value 44 | address = "${node.value}.${var.pve_domain}" 45 | } 46 | } 47 | } 48 | } 49 | 50 | provider "talos" { 51 | } 52 | -------------------------------------------------------------------------------- /reloader.tf: -------------------------------------------------------------------------------- 1 | # install reloader. 2 | # NB tls libraries typically load the certificates from ca-certificates.crt 3 | # file once, when they are started, and they never reload the file again. 4 | # reloader will automatically restart them when their configmap/secret 5 | # changes. 6 | # NB the default values are described at: 7 | # https://github.com/stakater/reloader/blob/v1.2.0/deployments/kubernetes/chart/reloader/values.yaml 8 | # NB make sure you are seeing the same version of the chart that you are installing. 9 | # see https://github.com/stakater/reloader 10 | # see https://artifacthub.io/packages/helm/stakater/reloader 11 | # see https://cert-manager.io/docs/tutorials/getting-started-with-trust-manager/ 12 | # see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template 13 | data "helm_template" "reloader" { 14 | namespace = "kube-system" 15 | name = "reloader" 16 | repository = "https://stakater.github.io/stakater-charts" 17 | chart = "reloader" 18 | # renovate: datasource=helm depName=reloader registryUrl=https://stakater.github.io/stakater-charts 19 | version = "2.2.6" 20 | kube_version = var.kubernetes_version 21 | api_versions = [] 22 | values = [file("${path.module}/helm/reloader-values.yaml")] 23 | } 24 | -------------------------------------------------------------------------------- /helm/argocd-values.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | domain: "argocd.wheezy.lab" 3 | 4 | configs: 5 | # Configuration principale ArgoCD 6 | cm: 7 | # URL publique d'ArgoCD 8 | url: "https://argocd.wheezy.lab" 9 | 10 | # Comptes API 11 | accounts.readonly: apiKey 12 | 13 | # Status badge 14 | statusbadge.enabled: true 15 | statusbadge.url: "https://argocd-badge.wheezy.fr/" 16 | 17 | # Configuration OIDC 18 | oidc.config: | 19 | name: Authentik 20 | issuer: https://auth.wheezy.fr/application/o/argo-cd/ 21 | clientID: mda1YuKv8TyyTG8ozm62BcLsXc6R2bfrM2f6NBBi 22 | clientSecret: $oidc.authentik.clientSecret 23 | requestedScopes: 24 | - openid 25 | - profile 26 | - email 27 | - groups 28 | requestedIDTokenClaims: 29 | groups: 30 | essential: true 31 | 32 | # Configuration RBAC 33 | rbac: 34 | policy.default: role:readonly 35 | policy.csv: | 36 | # Compte API readonly 37 | g, readonly, role:readonly 38 | 39 | # Groupes Authentik - Admins 40 | g, authentik Admins, role:admin 41 | g, argocd-admins, role:admin 42 | 43 | # Groupes Authentik - Developers 44 | g, argocd-developers, role:developer 45 | 46 | # Définition du rôle developer 47 | p, role:developer, applications, *, */*, allow 48 | p, role:developer, repositories, *, *, allow 49 | p, role:developer, projects, get, *, allow 50 | p, role:developer, clusters, get, *, allow 51 | p, role:developer, certificates, get, *, allow 52 | p, role:developer, logs, get, *, allow 53 | 54 | scopes: "[groups, email]" 55 | 56 | # Paramètres ArgoCD 57 | params: 58 | server.insecure: true 59 | server.repo.server.plaintext: true 60 | controller.repo.server.plaintext: true 61 | applicationsetcontroller.repo.server.plaintext: true 62 | reposerver.disable.tls: true 63 | 64 | # Dex désactivé 65 | dex: 66 | enabled: false 67 | 68 | # Configuration du serveur ArgoCD 69 | server: 70 | ingress: 71 | enabled: true 72 | tls: true 73 | -------------------------------------------------------------------------------- /helm/cilium-values.yaml: -------------------------------------------------------------------------------- 1 | ipam: 2 | mode: "kubernetes" 3 | 4 | securityContext: 5 | capabilities: 6 | ciliumAgent: 7 | - CHOWN 8 | - KILL 9 | - NET_ADMIN 10 | - NET_RAW 11 | - IPC_LOCK 12 | - SYS_ADMIN 13 | - SYS_RESOURCE 14 | - DAC_OVERRIDE 15 | - FOWNER 16 | - SETGID 17 | - SETUID 18 | cleanCiliumState: 19 | - NET_ADMIN 20 | - SYS_ADMIN 21 | - SYS_RESOURCE 22 | 23 | cgroup: 24 | autoMount: 25 | enabled: false 26 | hostRoot: "/sys/fs/cgroup" 27 | 28 | k8sServiceHost: "localhost" 29 | k8sServicePort: "7445" 30 | 31 | kubeProxyReplacement: true 32 | 33 | l2announcements: 34 | enabled: true 35 | 36 | extraArgs: 37 | - --devices=eth+ 38 | 39 | gatewayAPI: 40 | enabled: true 41 | gatewayClass: 42 | create: "true" 43 | enableProxyProtocol: true 44 | enableAlpn: true 45 | enableAppProtocol: true 46 | xffNumTrustedHops: 1 47 | externalTrafficPolicy: "Cluster" 48 | secretsNamespace: 49 | name: "cilium-secrets" 50 | sync: true 51 | create: true 52 | 53 | envoy: 54 | enabled: true 55 | resources: 56 | limits: 57 | cpu: 1000m 58 | memory: 512Mi 59 | requests: 60 | cpu: 100m 61 | memory: 128Mi 62 | 63 | ingressController: 64 | enabled: true 65 | default: true 66 | loadbalancerMode: "shared" 67 | enforceHttps: false 68 | 69 | hubble: 70 | enabled: true 71 | relay: 72 | enabled: true 73 | ui: 74 | enabled: true 75 | dashboards: 76 | enabled: true 77 | namespace: "observability" 78 | serviceMonitor: 79 | enabled: true 80 | metrics: 81 | enableOpenMetrics: true 82 | enabled: 83 | - dns 84 | - drop 85 | - tcp 86 | - flow 87 | - port-distribution 88 | - icmp 89 | - httpV2:exemplars=true;labelsContext=source_ip,source_namespace,source_workload,destination_ip,destination_namespace,destination_workload,traffic_direction 90 | 91 | prometheus: 92 | enabled: true 93 | 94 | operator: 95 | enabled: true 96 | prometheus: 97 | enabled: true 98 | resources: 99 | limits: 100 | cpu: 1000m 101 | memory: 1Gi 102 | requests: 103 | cpu: 100m 104 | memory: 128Mi 105 | 106 | l7Proxy: true 107 | bpf: 108 | masquerade: true 109 | -------------------------------------------------------------------------------- /cilium.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | # see https://docs.cilium.io/en/stable/network/lb-ipam/ 3 | # see https://docs.cilium.io/en/stable/network/l2-announcements/ 4 | # see the CiliumL2AnnouncementPolicy type at https://github.com/cilium/cilium/blob/v1.16.4/pkg/k8s/apis/cilium.io/v2alpha1/l2announcement_types.go#L23-L42 5 | # see the CiliumLoadBalancerIPPool type at https://github.com/cilium/cilium/blob/v1.16.4/pkg/k8s/apis/cilium.io/v2alpha1/lbipam_types.go#L23-L47 6 | cilium_manifest_objects = [ 7 | { 8 | apiVersion = "cilium.io/v2alpha1" 9 | kind = "CiliumL2AnnouncementPolicy" 10 | metadata = { 11 | name = "external" 12 | } 13 | spec = { 14 | loadBalancerIPs = true 15 | interfaces = [ 16 | "eth0", 17 | ] 18 | nodeSelector = { 19 | matchExpressions = [ 20 | { 21 | key = "node-role.kubernetes.io/control-plane" 22 | operator = "DoesNotExist" 23 | }, 24 | ] 25 | } 26 | } 27 | }, 28 | { 29 | apiVersion = "cilium.io/v2alpha1" 30 | kind = "CiliumLoadBalancerIPPool" 31 | metadata = { 32 | name = "external" 33 | } 34 | spec = { 35 | blocks = [ 36 | { 37 | start = cidrhost(var.cluster_node_network, var.cluster_node_network_load_balancer_first_hostnum) 38 | stop = cidrhost(var.cluster_node_network, var.cluster_node_network_load_balancer_last_hostnum) 39 | }, 40 | ] 41 | } 42 | } 43 | ] 44 | cilium_external_lb_manifest = join("---\n", [for d in local.cilium_manifest_objects : yamlencode(d)]) 45 | } 46 | 47 | // see https://www.talos.dev/v1.8/kubernetes-guides/network/deploying-cilium/#method-4-helm-manifests-inline-install 48 | // see https://docs.cilium.io/en/stable/network/servicemesh/ingress/ 49 | // see https://docs.cilium.io/en/stable/gettingstarted/hubble_setup/ 50 | // see https://docs.cilium.io/en/stable/gettingstarted/hubble/ 51 | // see https://docs.cilium.io/en/stable/helm-reference/#helm-reference 52 | // see https://github.com/cilium/cilium/releases 53 | // see https://github.com/cilium/cilium/tree/v1.16.4/install/kubernetes/cilium 54 | // see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template 55 | data "helm_template" "cilium" { 56 | namespace = "kube-system" 57 | name = "cilium" 58 | repository = "https://helm.cilium.io" 59 | chart = "cilium" 60 | # renovate: datasource=helm depName=cilium registryUrl=https://helm.cilium.io 61 | version = "1.18.3" 62 | kube_version = var.kubernetes_version 63 | api_versions = [] 64 | values = [file("${path.module}/helm/cilium-values.yaml")] 65 | } 66 | -------------------------------------------------------------------------------- /cert-manager.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | cert_manager_ingress_ca_manifests = [ 3 | # see https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1.ClusterIssuer 4 | { 5 | apiVersion = "cert-manager.io/v1" 6 | kind = "ClusterIssuer" 7 | metadata = { 8 | name = "selfsigned" 9 | } 10 | spec = { 11 | selfSigned = {} 12 | } 13 | }, 14 | # see https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1.Certificate 15 | { 16 | apiVersion = "cert-manager.io/v1" 17 | kind = "Certificate" 18 | metadata = { 19 | name = "ingress" 20 | namespace = "cert-manager" 21 | } 22 | spec = { 23 | isCA = true 24 | subject = { 25 | organizations = [ 26 | var.ingress_domain, 27 | ] 28 | organizationalUnits = [ 29 | "Kubernetes", 30 | ] 31 | } 32 | commonName = "Kubernetes Ingress" 33 | privateKey = { 34 | algorithm = "ECDSA" # NB Ed25519 is not yet supported by chrome 93 or firefox 91. 35 | size = 256 36 | } 37 | duration = "4320h" # NB 4320h (180 days). default is 2160h (90 days). 38 | secretName = "ingress-tls" 39 | issuerRef = { 40 | name = "selfsigned" 41 | kind = "ClusterIssuer" 42 | group = "cert-manager.io" 43 | } 44 | } 45 | }, 46 | # see https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1.ClusterIssuer 47 | { 48 | apiVersion = "cert-manager.io/v1" 49 | kind = "ClusterIssuer" 50 | metadata = { 51 | name = "ingress" 52 | } 53 | spec = { 54 | ca = { 55 | secretName = "ingress-tls" 56 | } 57 | } 58 | }, 59 | ] 60 | cert_manager_ingress_ca_manifest = join("---\n", [for d in local.cert_manager_ingress_ca_manifests : yamlencode(d)]) 61 | } 62 | 63 | # NB YOU CANNOT INSTALL MULTIPLE INSTANCES OF CERT-MANAGER IN A CLUSTER. 64 | # see https://artifacthub.io/packages/helm/cert-manager/cert-manager 65 | # see https://github.com/cert-manager/cert-manager/tree/master/deploy/charts/cert-manager 66 | # see https://cert-manager.io/docs/installation/supported-releases/ 67 | # see https://cert-manager.io/docs/configuration/selfsigned/#bootstrapping-ca-issuers 68 | # see https://cert-manager.io/docs/usage/ingress/ 69 | # see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template 70 | data "helm_template" "cert_manager" { 71 | namespace = "cert-manager" 72 | name = "cert-manager" 73 | repository = "https://charts.jetstack.io" 74 | chart = "cert-manager" 75 | # renovate: datasource=helm depName=cert-manager registryUrl=https://charts.jetstack.io 76 | version = "1.19.2" 77 | kube_version = var.kubernetes_version 78 | api_versions = [] 79 | values = [file("${path.module}/helm/cert-manager-values.yaml")] 80 | } 81 | -------------------------------------------------------------------------------- /hack/build_talos_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | # renovate: datasource=github-releases depName=siderolabs/talos 4 | talos_version="1.11.5" 5 | # renovate: datasource=docker depName=ghcr.io/siderolabs/qemu-guest-agent 6 | talos_qemu_guest_agent_extension_tag="10.1.2" 7 | # renovate: datasource=docker depName=ghcr.io/siderolabs/drbd 8 | talos_drbd_extension_tag="9.2.13-v1.10.4" 9 | # renovate: datasource=docker depName=ghcr.io/siderolabs/spin 10 | talos_spin_extension_tag="0.22.0" 11 | 12 | function step { 13 | echo "### $* ###" 14 | } 15 | 16 | function update-talos-extension { 17 | local variable_name="$1" 18 | local image_name="$2" 19 | local images="$3" 20 | local image="$(grep -F "$image_name:" <<<"$images")" 21 | local tag="${image#*:}" 22 | echo "updating the talos extension to $image..." 23 | variable_name="$variable_name" tag="$tag" perl -i -pe ' 24 | BEGIN { 25 | $var = $ENV{variable_name}; 26 | $val = $ENV{tag}; 27 | } 28 | s/^(\Q$var\E=).*/$1"$val"/; 29 | ' do 30 | } 31 | 32 | function update-talos-extensions { 33 | step "updating the talos extensions" 34 | local images="$(crane export "ghcr.io/siderolabs/extensions:v$talos_version" | tar x -O image-digests)" 35 | update-talos-extension talos_qemu_guest_agent_extension_tag ghcr.io/siderolabs/qemu-guest-agent "$images" 36 | update-talos-extension talos_drbd_extension_tag ghcr.io/siderolabs/drbd "$images" 37 | update-talos-extension talos_spin_extension_tag ghcr.io/siderolabs/spin "$images" 38 | } 39 | 40 | function build_talos_image { 41 | local talos_version_tag="v$talos_version" 42 | rm -rf tmp/talos 43 | mkdir -p tmp/talos 44 | cat >"tmp/talos/talos-$talos_version.yml" < kubernetes-ingress-ca-crt.pem 91 | } 92 | 93 | build_talos_image 94 | -------------------------------------------------------------------------------- /hack/configure_linstor.sh: -------------------------------------------------------------------------------- 1 | # renovate: datasource=github-releases depName=piraeusdatastore/piraeus-operator 2 | piraeus_operator_version="2.10.0" 3 | kubectl apply --server-side -k "https://github.com/piraeusdatastore/piraeus-operator//config/default?ref=v$piraeus_operator_version" 4 | kubectl wait pod --timeout=15m --for=condition=Ready -n piraeus-datastore -l app.kubernetes.io/component=piraeus-operator 5 | kubectl apply -n piraeus-datastore -f - <<'EOF' 6 | apiVersion: piraeus.io/v1 7 | kind: LinstorSatelliteConfiguration 8 | metadata: 9 | name: talos-loader-override 10 | spec: 11 | podTemplate: 12 | spec: 13 | initContainers: 14 | - name: drbd-shutdown-guard 15 | $patch: delete 16 | - name: drbd-module-loader 17 | $patch: delete 18 | volumes: 19 | - name: run-systemd-system 20 | $patch: delete 21 | - name: run-drbd-shutdown-guard 22 | $patch: delete 23 | - name: systemd-bus-socket 24 | $patch: delete 25 | - name: lib-modules 26 | $patch: delete 27 | - name: usr-src 28 | $patch: delete 29 | - name: etc-lvm-backup 30 | hostPath: 31 | path: /var/etc/lvm/backup 32 | type: DirectoryOrCreate 33 | - name: etc-lvm-archive 34 | hostPath: 35 | path: /var/etc/lvm/archive 36 | type: DirectoryOrCreate 37 | EOF 38 | kubectl apply -f - </dev/null 2>&1; do sleep 3; done 65 | if ! kubectl linstor storage-pool list --node "$node" --storage-pool lvm | grep -q lvm; then 66 | kubectl linstor physical-storage create-device-pool \ 67 | --pool-name lvm \ 68 | --storage-pool lvm \ 69 | lvm \ 70 | "$node" \ 71 | /dev/sdb 72 | fi 73 | done 74 | 75 | kubectl apply -f - </dev/null 2>&1; do sleep 3; done 92 | if ! kubectl linstor storage-pool list --node "$node" --storage-pool lvm-media | grep -q lvm-media; then 93 | kubectl linstor physical-storage create-device-pool \ 94 | --pool-name lvm-media \ 95 | --storage-pool lvm-media \ 96 | lvm \ 97 | "$node" \ 98 | /dev/sdc 99 | fi 100 | done 101 | -------------------------------------------------------------------------------- /argocd.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | argocd_domain = "argocd.${var.ingress_domain}" 3 | argocd_bootstrap_repo_url = var.bootstrap_repo_url 4 | argocd_namespace = "argocd" 5 | argocd_manifests = [ 6 | # create the argocd-server tls secret. 7 | # NB argocd-server will automatically reload this secret. 8 | # NB alternatively we could set the server.certificate.enabled helm value. but 9 | # that does not allow us to fully customize the certificate (e.g. subject). 10 | # see https://github.com/argoproj/argo-helm/blob/argo-cd-7.7.7/charts/argo-cd/templates/argocd-server/certificate.yaml 11 | # see https://argo-cd.readthedocs.io/en/stable/operator-manual/tls/ 12 | # see https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1.Certificate 13 | { 14 | apiVersion = "cert-manager.io/v1" 15 | kind = "Certificate" 16 | metadata = { 17 | name = "argocd-server" 18 | namespace = local.argocd_namespace 19 | } 20 | spec = { 21 | subject = { 22 | organizations = [ 23 | var.ingress_domain, 24 | ] 25 | organizationalUnits = [ 26 | "Kubernetes", 27 | ] 28 | } 29 | commonName = "Argo CD Server" 30 | dnsNames = [ 31 | local.argocd_domain, 32 | ] 33 | privateKey = { 34 | algorithm = "ECDSA" # NB Ed25519 is not yet supported by chrome 93 or firefox 91. 35 | size = 256 36 | } 37 | duration = "4320h" # NB 4320h (180 days). default is 2160h (90 days). 38 | secretName = "argocd-server-tls" 39 | issuerRef = { 40 | kind = "ClusterIssuer" 41 | name = "ingress" 42 | } 43 | } 44 | }, 45 | { 46 | apiVersion = "argoproj.io/v1alpha1" 47 | kind = "Application" 48 | metadata = { 49 | name = "bootstrap" 50 | namespace = local.argocd_namespace 51 | } 52 | spec = { 53 | destination = { 54 | namespace = local.argocd_namespace 55 | server = "https://kubernetes.default.svc" 56 | } 57 | project = "default" 58 | source = { 59 | path = "bootstrap" 60 | repoURL = local.argocd_bootstrap_repo_url 61 | targetRevision = "HEAD" 62 | } 63 | } 64 | } 65 | ] 66 | argocd_manifest = join("---\n", [for d in local.argocd_manifests : yamlencode(d)]) 67 | } 68 | 69 | # set the configuration. 70 | # NB the default values are described at: 71 | # https://github.com/argoproj/argo-helm/blob/argo-cd-7.7.7/charts/argo-cd/values.yaml 72 | # NB make sure you are seeing the same version of the chart that you are installing. 73 | # NB this disables the tls between argocd components, that is, the internal 74 | # cluster traffic does not uses tls, and only the ingress uses tls. 75 | # see https://github.com/argoproj/argo-helm/tree/main/charts/argo-cd#ssl-termination-at-ingress-controller 76 | # see https://argo-cd.readthedocs.io/en/stable/operator-manual/tls/#inbound-tls-options-for-argocd-server 77 | # see https://argo-cd.readthedocs.io/en/stable/operator-manual/tls/#disabling-tls-to-argocd-repo-server 78 | # see https://argo-cd.readthedocs.io/en/stable/operator-manual/tls/#disabling-tls-to-argocd-dex-server 79 | # see https://argo-cd.readthedocs.io/en/stable/operator-manual/installation/#helm 80 | # see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template 81 | data "helm_template" "argocd" { 82 | namespace = local.argocd_namespace 83 | name = "argocd" 84 | repository = "https://argoproj.github.io/argo-helm" 85 | chart = "argo-cd" 86 | # see https://artifacthub.io/packages/helm/argo/argo-cd 87 | # renovate: datasource=helm depName=argo-cd registryUrl=https://argoproj.github.io/argo-helm 88 | version = "9.1.7" # app version 3.0.0. 89 | kube_version = var.kubernetes_version 90 | api_versions = [] 91 | values = [file("${path.module}/helm/argocd-values.yaml")] 92 | } 93 | -------------------------------------------------------------------------------- /hack/linstor-restore.sh: -------------------------------------------------------------------------------- 1 | # =================================================================== 2 | # Script 2: Restoration de volumes LINSTOR 3 | # =================================================================== 4 | 5 | #!/bin/bash 6 | # linstor-restore.sh 7 | 8 | set -e 9 | 10 | SCRIPT_NAME="$(basename "$0")" 11 | NAMESPACE="piraeus-datastore" 12 | 13 | usage() { 14 | cat << EOF 15 | Usage: $SCRIPT_NAME [OPTIONS] RESOURCE_NAME SNAPSHOT_NAME [NEW_RESOURCE_NAME] 16 | 17 | Restaure une ressource LINSTOR depuis un snapshot 18 | 19 | OPTIONS: 20 | -n, --namespace NAMESPACE Namespace du piraeus-operator (défaut: $NAMESPACE) 21 | -f, --force Force la restauration même si la ressource existe 22 | -h, --help Affiche cette aide 23 | 24 | ARGUMENTS: 25 | RESOURCE_NAME Nom de la ressource source 26 | SNAPSHOT_NAME Nom du snapshot à restaurer 27 | NEW_RESOURCE_NAME Nom de la nouvelle ressource (optionnel) 28 | 29 | EXEMPLES: 30 | $SCRIPT_NAME my-pvc backup-20241227-my-pvc 31 | $SCRIPT_NAME my-db backup-20241227-my-db my-db-restored 32 | $SCRIPT_NAME -f my-vol weekly-backup-my-vol 33 | EOF 34 | } 35 | 36 | restore_from_snapshot() { 37 | local source_resource="$1" 38 | local snapshot_name="$2" 39 | local target_resource="$3" 40 | local force="$4" 41 | 42 | echo "🔄 Restauration depuis le snapshot '$snapshot_name'..." 43 | 44 | # Vérifier si le snapshot existe 45 | echo "🔍 Vérification de l'existence du snapshot..." 46 | if ! kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 47 | linstor snapshot list "$source_resource" | grep -q "$snapshot_name"; then 48 | echo "❌ Snapshot '$snapshot_name' introuvable pour la ressource '$source_resource'" 49 | exit 1 50 | fi 51 | 52 | # Vérifier si la ressource cible existe déjà 53 | if [ "$force" != "true" ]; then 54 | if kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 55 | linstor resource list | grep -q "^| $target_resource "; then 56 | echo "❌ La ressource '$target_resource' existe déjà. Utilisez -f pour forcer." 57 | exit 1 58 | fi 59 | fi 60 | 61 | # Restaurer depuis le snapshot 62 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 63 | linstor snapshot volume-definition restore \ 64 | --from-resource "$source_resource" \ 65 | --from-snapshot "$snapshot_name" \ 66 | --to-resource "$target_resource" 67 | 68 | if [ $? -eq 0 ]; then 69 | echo "✅ Restauration réussie !" 70 | echo "📋 Informations de la ressource restaurée :" 71 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 72 | linstor resource list-volumes "$target_resource" 73 | else 74 | echo "❌ Erreur lors de la restauration" 75 | exit 1 76 | fi 77 | } 78 | 79 | # Parsing des arguments 80 | FORCE="false" 81 | RESOURCE_NAME="" 82 | SNAPSHOT_NAME="" 83 | NEW_RESOURCE_NAME="" 84 | 85 | while [[ $# -gt 0 ]]; do 86 | case $1 in 87 | -n|--namespace) 88 | NAMESPACE="$2" 89 | shift 2 90 | ;; 91 | -f|--force) 92 | FORCE="true" 93 | shift 94 | ;; 95 | -h|--help) 96 | usage 97 | exit 0 98 | ;; 99 | -*) 100 | echo "Option inconnue: $1" >&2 101 | usage >&2 102 | exit 1 103 | ;; 104 | *) 105 | if [ -z "$RESOURCE_NAME" ]; then 106 | RESOURCE_NAME="$1" 107 | elif [ -z "$SNAPSHOT_NAME" ]; then 108 | SNAPSHOT_NAME="$1" 109 | elif [ -z "$NEW_RESOURCE_NAME" ]; then 110 | NEW_RESOURCE_NAME="$1" 111 | else 112 | echo "Trop d'arguments" >&2 113 | usage >&2 114 | exit 1 115 | fi 116 | shift 117 | ;; 118 | esac 119 | done 120 | 121 | if [ -z "$RESOURCE_NAME" ] || [ -z "$SNAPSHOT_NAME" ]; then 122 | echo "❌ Nom de ressource et nom de snapshot requis" >&2 123 | usage >&2 124 | exit 1 125 | fi 126 | 127 | # Si pas de nouveau nom spécifié, utiliser le nom original avec suffixe 128 | if [ -z "$NEW_RESOURCE_NAME" ]; then 129 | NEW_RESOURCE_NAME="${RESOURCE_NAME}-restored-$(date +%Y%m%d-%H%M%S)" 130 | fi 131 | 132 | echo "🚀 Démarrage de la restauration LINSTOR" 133 | echo " Ressource source: $RESOURCE_NAME" 134 | echo " Snapshot: $SNAPSHOT_NAME" 135 | echo " Ressource cible: $NEW_RESOURCE_NAME" 136 | echo " Namespace: $NAMESPACE" 137 | echo "" 138 | 139 | restore_from_snapshot "$RESOURCE_NAME" "$SNAPSHOT_NAME" "$NEW_RESOURCE_NAME" "$FORCE" 140 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "proxmox_pve_node_name" { 2 | type = list(string) 3 | default = ["pve01", "pve02", "pve03"] 4 | } 5 | 6 | variable "talos_version" { 7 | type = string 8 | default = "1.8.3" 9 | validation { 10 | condition = can(regex("^\\d+(\\.\\d+)+", var.talos_version)) 11 | error_message = "Must be a version number." 12 | } 13 | } 14 | 15 | variable "kubernetes_version" { 16 | type = string 17 | # renovate: datasource=github-releases depName=siderolabs/kubelet 18 | default = "1.34.3" 19 | validation { 20 | condition = can(regex("^\\d+(\\.\\d+)+", var.kubernetes_version)) 21 | error_message = "Must be a version number." 22 | } 23 | } 24 | 25 | variable "cluster_name" { 26 | description = "A name to provide for the Talos cluster" 27 | type = string 28 | default = "example" 29 | } 30 | 31 | variable "cluster_vip" { 32 | description = "The virtual IP (VIP) address of the Kubernetes API server. Ensure it is synchronized with the 'cluster_endpoint' variable." 33 | type = string 34 | default = "172.31.1.10" 35 | } 36 | 37 | variable "cluster_endpoint" { 38 | description = "The virtual IP (VIP) endpoint of the Kubernetes API server. Ensure it is synchronized with the 'cluster_vip' variable." 39 | type = string 40 | default = "https://172.31.1.10:6443" 41 | } 42 | 43 | variable "cluster_node_network_gateway" { 44 | description = "The IP network gateway of the cluster nodes" 45 | type = string 46 | default = "172.31.1.1" 47 | } 48 | 49 | variable "cluster_node_network" { 50 | description = "The IP network of the cluster nodes" 51 | type = string 52 | default = "172.31.1.0/24" 53 | } 54 | 55 | variable "cluster_node_network_first_controller_hostnum" { 56 | description = "The hostnum of the first controller host" 57 | type = number 58 | default = 40 59 | } 60 | 61 | variable "cluster_node_network_first_worker_hostnum" { 62 | description = "The hostnum of the first worker host" 63 | type = number 64 | default = 50 65 | } 66 | 67 | variable "cluster_node_network_load_balancer_first_hostnum" { 68 | description = "The hostnum of the first load balancer host" 69 | type = number 70 | default = 70 71 | } 72 | 73 | variable "cluster_node_network_load_balancer_last_hostnum" { 74 | description = "The hostnum of the last load balancer host" 75 | type = number 76 | default = 80 77 | } 78 | 79 | variable "bootstrap_repo_url" { 80 | description = "the DNS domain of the ingress resources" 81 | type = string 82 | default = "https://github.com/florianspk/argocd-apps-homelab.git" 83 | } 84 | 85 | variable "ingress_domain" { 86 | description = "the DNS domain of the ingress resources" 87 | type = string 88 | default = "example.test" 89 | } 90 | 91 | variable "pve_domain" { 92 | description = "The DNS domaine of the pve" 93 | type = string 94 | } 95 | 96 | variable "controller_count" { 97 | type = number 98 | default = 1 99 | validation { 100 | condition = var.controller_count >= 1 101 | error_message = "Must be 1 or more." 102 | } 103 | } 104 | 105 | variable "worker_count" { 106 | type = number 107 | default = 2 108 | validation { 109 | condition = var.worker_count >= 1 110 | error_message = "Must be 1 or more." 111 | } 112 | } 113 | 114 | variable "prefix" { 115 | type = string 116 | default = "vm-talos" 117 | } 118 | 119 | variable "default-iso-datastoreid" { 120 | type = string 121 | default = "local" 122 | } 123 | variable "default-datastoreid" { 124 | type = string 125 | default = "local-lvm-1" 126 | } 127 | 128 | variable "datastore_per_node" { 129 | type = map(string) 130 | default = { 131 | #exemple : "pve01" = "ssd-storage" 132 | # "pve02" = "local-lvm-2" 133 | #pas besoin d’ajouter un noeud ici s’il doit utiliser la valeur par défaut 134 | } 135 | } 136 | 137 | variable "api_token" { 138 | type = string 139 | description = "secret to auth proxmox" 140 | default = "XXXXXXXXXXX" 141 | } 142 | 143 | variable "path_private_key" { 144 | type = string 145 | description = "path to the private key" 146 | default = "~/.ssh/terraform_id_ed25519" 147 | } 148 | 149 | variable "tags" { 150 | type = list(string) 151 | default = ["talos", "terraform"] 152 | description = "values to tag the vm" 153 | } 154 | 155 | variable "argocd_enabled" { 156 | type = bool 157 | default = true 158 | description = "enable argocd" 159 | 160 | } 161 | 162 | variable "ntp_serveurs" { 163 | type = list(string) 164 | default = ["pool.ntp.org"] 165 | } 166 | 167 | variable "dns_serveurs" { 168 | type = list(string) 169 | default = ["1.1.1.1", "8.8.8.8"] 170 | } 171 | 172 | variable "extra_disks_per_node" { 173 | description = "Disques supplémentaires par nœud" 174 | type = map(list(object({ 175 | size = number 176 | datastore_id = string 177 | interface = string 178 | ssd = optional(bool, true) 179 | discard = optional(string, "on") 180 | file_format = optional(string, "raw") 181 | iothread = optional(bool, true) 182 | }))) 183 | default = {} 184 | } 185 | -------------------------------------------------------------------------------- /proxmox.tf: -------------------------------------------------------------------------------- 1 | resource "random_shuffle" "node_shuffle" { 2 | input = var.proxmox_pve_node_name 3 | } 4 | 5 | locals { 6 | # Fonction pour déterminer le datastore à utiliser selon le nœud 7 | get_datastore_for_controller = { 8 | for i in range(var.controller_count) : i => lookup( 9 | var.datastore_per_node, 10 | var.proxmox_pve_node_name[i % length(var.proxmox_pve_node_name)], 11 | var.default-datastoreid 12 | ) 13 | } 14 | 15 | get_datastore_for_worker = { 16 | for i in range(var.worker_count) : i => lookup( 17 | var.datastore_per_node, 18 | var.proxmox_pve_node_name[i % length(var.proxmox_pve_node_name)], 19 | var.default-datastoreid 20 | ) 21 | } 22 | } 23 | 24 | 25 | resource "proxmox_virtual_environment_file" "talos" { 26 | for_each = toset(var.proxmox_pve_node_name) 27 | node_name = each.value 28 | datastore_id = var.default-iso-datastoreid 29 | content_type = "iso" 30 | source_file { 31 | path = "tmp/talos/talos-${var.talos_version}.qcow2" 32 | file_name = "talos-${var.talos_version}.img" 33 | } 34 | } 35 | 36 | resource "proxmox_virtual_environment_vm" "controller" { 37 | count = var.controller_count 38 | name = "${var.prefix}-${local.controller_nodes[count.index].name}" 39 | node_name = var.proxmox_pve_node_name[count.index % length(var.proxmox_pve_node_name)] 40 | tags = sort(concat(var.tags, ["controller"])) 41 | stop_on_destroy = true 42 | bios = "ovmf" 43 | machine = "q35" 44 | scsi_hardware = "virtio-scsi-single" 45 | operating_system { 46 | type = "l26" 47 | } 48 | cpu { 49 | type = "host" 50 | cores = 2 51 | } 52 | memory { 53 | dedicated = 4 * 1024 54 | } 55 | vga { 56 | type = "qxl" 57 | } 58 | network_device { 59 | bridge = "vxvnet1" 60 | mtu = 1 61 | } 62 | tpm_state { 63 | datastore_id = local.get_datastore_for_controller[count.index] 64 | version = "v2.0" 65 | } 66 | efi_disk { 67 | datastore_id = local.get_datastore_for_controller[count.index] 68 | file_format = "raw" 69 | type = "4m" 70 | } 71 | disk { 72 | datastore_id = local.get_datastore_for_controller[count.index] 73 | interface = "scsi0" 74 | iothread = true 75 | ssd = true 76 | discard = "on" 77 | size = 30 78 | file_format = "raw" 79 | file_id = proxmox_virtual_environment_file.talos[var.proxmox_pve_node_name[count.index % length(var.proxmox_pve_node_name)]].id 80 | } 81 | agent { 82 | enabled = true 83 | trim = true 84 | } 85 | initialization { 86 | datastore_id = local.get_datastore_for_controller[count.index] 87 | ip_config { 88 | ipv4 { 89 | address = "${local.controller_nodes[count.index].address}/24" 90 | gateway = var.cluster_node_network_gateway 91 | } 92 | } 93 | } 94 | } 95 | 96 | resource "proxmox_virtual_environment_vm" "worker" { 97 | count = var.worker_count 98 | name = "${var.prefix}-${local.worker_nodes[count.index].name}" 99 | node_name = var.proxmox_pve_node_name[count.index % length(var.proxmox_pve_node_name)] 100 | tags = sort(concat(var.tags, ["worker"])) 101 | stop_on_destroy = true 102 | bios = "ovmf" 103 | machine = "q35" 104 | scsi_hardware = "virtio-scsi-single" 105 | operating_system { 106 | type = "l26" 107 | } 108 | cpu { 109 | type = "host" 110 | cores = 4 111 | } 112 | memory { 113 | dedicated = 6 * 1024 114 | } 115 | vga { 116 | type = "qxl" 117 | } 118 | network_device { 119 | bridge = "vxvnet1" 120 | mtu = 1 121 | } 122 | tpm_state { 123 | datastore_id = local.get_datastore_for_worker[count.index] 124 | version = "v2.0" 125 | } 126 | efi_disk { 127 | datastore_id = local.get_datastore_for_worker[count.index] 128 | file_format = "raw" 129 | type = "4m" 130 | } 131 | disk { 132 | datastore_id = local.get_datastore_for_worker[count.index] 133 | interface = "scsi0" 134 | iothread = true 135 | ssd = true 136 | discard = "on" 137 | size = 40 138 | file_format = "raw" 139 | file_id = proxmox_virtual_environment_file.talos[var.proxmox_pve_node_name[count.index % length(var.proxmox_pve_node_name)]].id 140 | } 141 | disk { 142 | datastore_id = local.get_datastore_for_worker[count.index] 143 | interface = "scsi1" 144 | iothread = true 145 | ssd = true 146 | discard = "on" 147 | size = 60 148 | file_format = "raw" 149 | } 150 | dynamic "disk" { 151 | for_each = lookup(var.extra_disks_per_node, var.proxmox_pve_node_name[count.index % length(var.proxmox_pve_node_name)], []) 152 | content { 153 | size = disk.value.size 154 | datastore_id = disk.value.datastore_id 155 | interface = disk.value.interface 156 | iothread = try(disk.value.iothread, true) 157 | ssd = try(disk.value.ssd, true) 158 | discard = try(disk.value.discard, "on") 159 | file_format = try(disk.value.file_format, "raw") 160 | } 161 | } 162 | agent { 163 | enabled = true 164 | trim = true 165 | } 166 | initialization { 167 | datastore_id = local.get_datastore_for_worker[count.index] 168 | ip_config { 169 | ipv4 { 170 | address = "${local.worker_nodes[count.index].address}/24" 171 | gateway = var.cluster_node_network_gateway 172 | } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /hack/linstor-snapshot-manager.sh: -------------------------------------------------------------------------------- 1 | 2 | # =================================================================== 3 | # Script 3: Gestion et nettoyage des snapshots 4 | # =================================================================== 5 | 6 | #!/bin/bash 7 | # linstor-snapshot-manager.sh 8 | 9 | set -e 10 | 11 | SCRIPT_NAME="$(basename "$0")" 12 | NAMESPACE="piraeus-datastore" 13 | 14 | usage() { 15 | cat << EOF 16 | Usage: $SCRIPT_NAME [OPTIONS] COMMAND [ARGS...] 17 | 18 | Gestion avancée des snapshots LINSTOR 19 | 20 | COMMANDS: 21 | list [RESOURCE] Liste tous les snapshots (ou d'une ressource) 22 | clean RESOURCE DAYS Supprime les snapshots plus anciens que X jours 23 | delete RESOURCE SNAPSHOT Supprime un snapshot specific 24 | info RESOURCE SNAPSHOT Affiche les détails d'un snapshot 25 | 26 | OPTIONS: 27 | -n, --namespace NAMESPACE Namespace du piraeus-operator (défaut: $NAMESPACE) 28 | -y, --yes Confirme automatiquement les suppressions 29 | -h, --help Affiche cette aide 30 | 31 | EXEMPLES: 32 | $SCRIPT_NAME list 33 | $SCRIPT_NAME list my-pvc 34 | $SCRIPT_NAME clean my-pvc 7 35 | $SCRIPT_NAME delete my-pvc backup-20241220-my-pvc 36 | $SCRIPT_NAME info my-pvc backup-20241227-my-pvc 37 | EOF 38 | } 39 | 40 | list_snapshots() { 41 | local resource="$1" 42 | 43 | echo "📋 Liste des snapshots LINSTOR" 44 | echo "================================" 45 | 46 | if [ -n "$resource" ]; then 47 | echo "Ressource: $resource" 48 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 49 | linstor snapshot list "$resource" 50 | else 51 | echo "Toutes les ressources:" 52 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 53 | linstor snapshot list 54 | fi 55 | } 56 | 57 | clean_old_snapshots() { 58 | local resource="$1" 59 | local days="$2" 60 | local auto_confirm="$3" 61 | 62 | echo "🧹 Nettoyage des snapshots de '$resource' plus anciens que $days jours" 63 | 64 | # Récupérer la liste des snapshots avec dates 65 | local snapshots 66 | snapshots=$(kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 67 | linstor snapshot list "$resource" --parsable | tail -n +2) 68 | 69 | if [ -z "$snapshots" ]; then 70 | echo "ℹ️ Aucun snapshot trouvé pour la ressource '$resource'" 71 | return 72 | fi 73 | 74 | local cutoff_date 75 | cutoff_date=$(date -d "$days days ago" +%s) 76 | 77 | echo "$snapshots" | while IFS='|' read -r res_name snap_name created_date rest; do 78 | # Nettoyer les espaces 79 | snap_name=$(echo "$snap_name" | tr -d ' ') 80 | created_date=$(echo "$created_date" | tr -d ' ') 81 | 82 | # Convertir la date du snapshot en timestamp 83 | local snap_timestamp 84 | snap_timestamp=$(date -d "$created_date" +%s 2>/dev/null || echo "0") 85 | 86 | if [ "$snap_timestamp" -lt "$cutoff_date" ] && [ "$snap_timestamp" -gt "0" ]; then 87 | echo "🗑️ Snapshot à supprimer: $snap_name (créé le $created_date)" 88 | 89 | if [ "$auto_confirm" = "true" ]; then 90 | delete_snapshot "$resource" "$snap_name" 91 | else 92 | read -p "Supprimer ce snapshot ? (y/N): " confirm 93 | if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then 94 | delete_snapshot "$resource" "$snap_name" 95 | fi 96 | fi 97 | fi 98 | done 99 | } 100 | 101 | delete_snapshot() { 102 | local resource="$1" 103 | local snapshot="$2" 104 | 105 | echo "🗑️ Suppression du snapshot '$snapshot' de la ressource '$resource'..." 106 | 107 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 108 | linstor snapshot delete "$resource" "$snapshot" 109 | 110 | if [ $? -eq 0 ]; then 111 | echo "✅ Snapshot supprimé avec succès" 112 | else 113 | echo "❌ Erreur lors de la suppression" 114 | fi 115 | } 116 | 117 | snapshot_info() { 118 | local resource="$1" 119 | local snapshot="$2" 120 | 121 | echo "📋 Informations détaillées du snapshot" 122 | echo "======================================" 123 | echo "Ressource: $resource" 124 | echo "Snapshot: $snapshot" 125 | echo "" 126 | 127 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 128 | linstor snapshot list "$resource" "$snapshot" 129 | } 130 | 131 | # Parsing des arguments 132 | AUTO_CONFIRM="false" 133 | COMMAND="" 134 | ARGS=() 135 | 136 | while [[ $# -gt 0 ]]; do 137 | case $1 in 138 | -n|--namespace) 139 | NAMESPACE="$2" 140 | shift 2 141 | ;; 142 | -y|--yes) 143 | AUTO_CONFIRM="true" 144 | shift 145 | ;; 146 | -h|--help) 147 | usage 148 | exit 0 149 | ;; 150 | -*) 151 | echo "Option inconnue: $1" >&2 152 | usage >&2 153 | exit 1 154 | ;; 155 | *) 156 | if [ -z "$COMMAND" ]; then 157 | COMMAND="$1" 158 | else 159 | ARGS+=("$1") 160 | fi 161 | shift 162 | ;; 163 | esac 164 | done 165 | 166 | if [ -z "$COMMAND" ]; then 167 | echo "❌ Commande requise" >&2 168 | usage >&2 169 | exit 1 170 | fi 171 | 172 | case "$COMMAND" in 173 | list) 174 | list_snapshots "${ARGS[0]}" 175 | ;; 176 | clean) 177 | if [ ${#ARGS[@]} -lt 2 ]; then 178 | echo "❌ 'clean' nécessite RESOURCE et DAYS" >&2 179 | usage >&2 180 | exit 1 181 | fi 182 | clean_old_snapshots "${ARGS[0]}" "${ARGS[1]}" "$AUTO_CONFIRM" 183 | ;; 184 | delete) 185 | if [ ${#ARGS[@]} -lt 2 ]; then 186 | echo "❌ 'delete' nécessite RESOURCE et SNAPSHOT" >&2 187 | usage >&2 188 | exit 1 189 | fi 190 | delete_snapshot "${ARGS[0]}" "${ARGS[1]}" 191 | ;; 192 | info) 193 | if [ ${#ARGS[@]} -lt 2 ]; then 194 | echo "❌ 'info' nécessite RESOURCE et SNAPSHOT" >&2 195 | usage >&2 196 | exit 1 197 | fi 198 | snapshot_info "${ARGS[0]}" "${ARGS[1]}" 199 | ;; 200 | *) 201 | echo "❌ Commande inconnue: $COMMAND" >&2 202 | usage >&2 203 | exit 1 204 | ;; 205 | esac 206 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ## 🚀 Mon Homelab Kubernetes 🚧 4 | 5 | 6 | 7 | 8 | _... géré avec Terraform, ArgoCD, et Talos Linux_ 🤖 9 | 10 |
11 | 12 |
13 | 14 | [![Talos](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Ftalos_version&style=for-the-badge&logo=talos&logoColor=white&label=Talos&color=blue)](https://talos.dev)   15 | [![Kubernetes](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Fkubelet_version&style=for-the-badge&logo=kubernetes&logoColor=white&label=Kubernetes&color=blue)](https://kubernetes.io)   16 | [![ArgoCD](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Fargocd_version&style=for-the-badge&logo=argo&logoColor=white&label=ArgoCD&color=blue)](https://argo-cd.readthedocs.io)   17 | [![Terraform](https://img.shields.io/badge/Terraform-IaC-blue?style=for-the-badge&logo=terraform&logoColor=white)](https://terraform.io) 18 | 19 |
20 | 21 |
22 | 23 | [![Tailscale](https://img.shields.io/badge/Tailscale-VPN-brightgreen?style=for-the-badge&logo=tailscale&logoColor=white)](https://tailscale.com)   24 | [![Cloudflare](https://img.shields.io/badge/Cloudflare-ZeroTrust-brightgreen?style=for-the-badge&logo=cloudflare&logoColor=white)](https://www.cloudflare.com)   25 | [![Proxmox](https://img.shields.io/badge/Proxmox-VE-brightgreen?style=for-the-badge&logo=proxmox&logoColor=white)](https://proxmox.com) 26 | 27 |
28 | 29 |
30 | 31 | [![CPU-Usage](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Fcluster_cpu_usage&style=flat-square&label=CPU)]("")   32 | [![Memory-Usage](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Fcluster_memory_usage&style=flat-square&label=Memory)]("")   33 | [![Node-Count](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Fcluster_nodes_ready)]("")   34 | [![Pod-Count](https://img.shields.io/endpoint?url=https%3A%2F%2Fkromgo.wheezy.fr%2Fcluster_pods_running)]("")   35 |
36 | 37 | --- 38 | 39 | ## 💡 Vue d'ensemble 40 | 41 | Ce repository contient l'infrastructure complète de mon homelab Kubernetes. J'applique les principes d'Infrastructure as Code (IaC) et GitOps en utilisant [Terraform](https://www.terraform.io/) pour le provisioning, [Talos Linux](https://www.talos.dev/) comme OS des nœuds, et [ArgoCD](https://argo-cd.readthedocs.io/) pour le déploiement des applications. 42 | 43 | L'infrastructure est hébergée sur [Proxmox VE](https://proxmox.com/) et j'utilise [Tailscale](https://tailscale.com/) pour l'accès privé sécurisé ainsi que [Cloudflare Zero Trust](https://www.cloudflare.com/) pour l'exposition publique des services. 44 | 45 | --- 46 | 47 | ## 🌱 Kubernetes 48 | 49 | Mon cluster Kubernetes est déployé avec [Talos Linux](https://www.talos.dev/) sur deux serveurs physiques sous Proxmox VE. Le cluster utilise un stockage distribué avec [Linstor](https://linbit.com/linstor/) pour la persistance des données. 50 | 51 | Le repository des applications ArgoCD se trouve ici : [argocd-apps-homelab](https://github.com/florianspk/argocd-apps-homelab) 52 | 53 | ### Composants principaux 54 | 55 | - **[talos](https://www.talos.dev/)** : OS minimal et sécurisé pour Kubernetes 56 | - **[cilium](https://github.com/cilium/cilium)** : CNI basé sur eBPF avec ingress controller intégré 57 | - **[argocd](https://argo-cd.readthedocs.io/)** : Déploiement GitOps des applications 58 | - **[cert-manager](https://github.com/cert-manager/cert-manager)** : Gestion automatique des certificats SSL/TLS 59 | - **[trust-manager](https://github.com/cert-manager/trust-manager)** : Distribution des CA pour les DNS privés 60 | - **[linstor](https://linbit.com/linstor/)** : Stockage distribué haute disponibilité 61 | 62 | ### GitOps avec ArgoCD 63 | 64 | [ArgoCD](https://argo-cd.readthedocs.io/) surveille le repository [argocd-apps-homelab](https://github.com/florianspk/argocd-apps-homelab) et synchronise automatiquement l'état désiré des applications avec le cluster Kubernetes. 65 | 66 | Les applications sont organisées par famille et par cluster, permettant une gestion granulaire des déploiements et des mises à jour. 67 | 68 | ### Structure des répertoires 69 | 70 | ```sh 71 | 📁 argocd-apps-homelab 72 | ├── 📁 apps 73 | │ ├── 📁 apps-ops 74 | │ ├── 📁 apps-monitoring 75 | │ ├── 📁 kube-prometheus-stack 76 | │ │ ├── 📁 extras 77 | │ │ ├── 📄 prd.json 78 | │ │ ├── 📄 dev.json 79 | │ │ └── 📄 staging.json 80 | │ └── 📁 apps-ops 81 | │ 82 | ├── 📁 bootstrap 83 | ├── 📁 projects 84 | └── 📄 renovate.json 85 | ``` 86 | 87 | --- 88 | 89 | ## 🌎 Réseau 90 | 91 | ### DNS et accès sécurisé 92 | 93 | Le cluster utilise une approche hybride pour la gestion DNS et l'accès réseau : 94 | 95 | - **DNS privé** : Intégration avec le DNS interne du cluster via cert-manager et une CA privée 96 | - **Tailscale** : VPN mesh pour l'accès administratif aux interfaces (pfSense, Proxmox) 97 | - **Split DNS** : Configuration sur Tailscale pour résoudre les services internes 98 | - **Cloudflare Zero Trust** : Exposition sécurisée des services publics 99 | 100 | ### Ingress et Load Balancing 101 | 102 | Cilium assure à la fois les fonctions de CNI et d'ingress controller, offrant : 103 | - Load balancing L4/L7 natif 104 | - Politique réseau fine avec eBPF 105 | - Observabilité réseau avancée 106 | - Intégration native avec les services Kubernetes 107 | 108 | --- 109 | 110 | ## ⚙ Infrastructure 111 | 112 | ### Matériel 113 | 114 | | Serveur | CPU | RAM | Stockage | Rôle | Spécificités | 115 | |---------|-----|-----|----------|------|-------------| 116 | | pve01 | Intel i5 5ème gen | 32GB | 4 To SSD | Kubernetes Master/Worker | NVIDIA GTX 1060 | 117 | | pve02 | Intel i5 5ème gen | 32GB | 1 To SSD | Kubernetes Worker | - | 118 | 119 | ### Hyperviseur 120 | 121 | - **[Proxmox VE](https://proxmox.com/)** : Plateforme de virtualisation pour héberger les VMs Talos 122 | - **Terraform Provider** : Automatisation du provisioning des ressources Proxmox 123 | 124 | ### Stockage 125 | 126 | - **[Linstor](https://linbit.com/linstor/)** : Stockage distribué DRBD pour la haute disponibilité 127 | - **Configuration manuelle** : Scripts de déploiement dans le dossier `hack/` 128 | - **Réplication** : Données répliquées entre les deux nœuds 129 | 130 | --- 131 | 132 | ## 😶 Services Cloud 133 | 134 | Bien que la majorité de l'infrastructure soit auto-hébergée, je m'appuie sur quelques services cloud pour les besoins critiques : 135 | 136 | | Service | Utilisation | Coût | 137 | |---------|-------------|------| 138 | | [Tailscale](https://tailscale.com/) | VPN mesh et accès administratif | Gratuit | 139 | | [Cloudflare](https://www.cloudflare.com/) | Zero Trust et DNS public | Gratuit| 140 | | [GitHub](https://github.com/) | Hébergement des repositories et CI/CD | Gratuit | 141 | 142 | --- 143 | 144 | ## 🚀 Déploiement 145 | 146 | ### Prérequis 147 | 148 | - Proxmox VE configuré avec les VMs 149 | - Terraform installé 150 | - Talosctl installé 151 | - Accès aux credentials Proxmox 152 | 153 | ### Étapes de déploiement 154 | 155 | 1. **Build custom talos image** 156 | ```bash 157 | chmod +x ./hack/build_talos_image.sh 158 | ./hack/build_talos_image.sh 159 | ``` 160 | 161 | 2. **Provisioning Terraform** 162 | ```bash 163 | terraform init 164 | terraform plan 165 | terraform apply 166 | ``` 167 | 168 | 169 | 3. **Déploiement Linstor** 170 | ```bash 171 | chmod +x ./hack/configure_linstor 172 | ./hack/configure_linstor 173 | ``` 174 | 175 | 4. **Configuration ArgoCD** 176 | - ArgoCD se déploie automatiquement 177 | - Fork le repo [argocd-apps-homelab](https://github.com/florianspk/argocd-apps-homelab) et modifier bootstrap_repo_url 178 | 179 | --- 180 | 181 | ## 📝 Licence 182 | 183 | Ce projet est sous licence MIT. Voir le fichier [LICENSE](LICENSE) pour plus de détails. 184 | -------------------------------------------------------------------------------- /talos.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | controller_nodes = [ 3 | for i in range(var.controller_count) : { 4 | name = "c${i}" 5 | address = cidrhost(var.cluster_node_network, var.cluster_node_network_first_controller_hostnum + i) 6 | } 7 | ] 8 | worker_nodes = [ 9 | for i in range(var.worker_count) : { 10 | name = "w${i}" 11 | address = cidrhost(var.cluster_node_network, var.cluster_node_network_first_worker_hostnum + i) 12 | } 13 | ] 14 | common_machine_config = { 15 | machine = { 16 | # NB the install section changes are only applied after a talos upgrade 17 | # (which we do not do). instead, its preferred to create a custom 18 | # talos image, which is created in the installed state. 19 | #install = {} 20 | features = { 21 | # see https://www.talos.dev/v1.8/kubernetes-guides/configuration/kubeprism/ 22 | # see talosctl -n $c0 read /etc/kubernetes/kubeconfig-kubelet | yq .clusters[].cluster.server 23 | # NB if you use a non-default CNI, you must configure it to use the 24 | # https://localhost:7445 kube-apiserver endpoint. 25 | kubePrism = { 26 | enabled = true 27 | port = 7445 28 | } 29 | # see https://www.talos.dev/v1.8/talos-guides/network/host-dns/ 30 | hostDNS = { 31 | enabled = true 32 | forwardKubeDNSToHost = true 33 | } 34 | } 35 | kernel = { 36 | modules = [ 37 | // piraeus dependencies. 38 | { 39 | name = "drbd" 40 | parameters = [ 41 | "usermode_helper=disabled", 42 | ] 43 | }, 44 | { 45 | name = "drbd_transport_tcp" 46 | }, 47 | ] 48 | } 49 | } 50 | cluster = { 51 | # see https://www.talos.dev/v1.8/talos-guides/discovery/ 52 | # see https://www.talos.dev/v1.8/reference/configuration/#clusterdiscoveryconfig 53 | discovery = { 54 | enabled = true 55 | registries = { 56 | kubernetes = { 57 | disabled = false 58 | } 59 | service = { 60 | disabled = true 61 | } 62 | } 63 | } 64 | network = { 65 | cni = { 66 | name = "none" 67 | } 68 | } 69 | proxy = { 70 | disabled = true 71 | } 72 | } 73 | } 74 | } 75 | 76 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/resources/machine_secrets 77 | resource "talos_machine_secrets" "talos" { 78 | talos_version = "v${var.talos_version}" 79 | } 80 | 81 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/data-sources/machine_configuration 82 | data "talos_machine_configuration" "controller" { 83 | cluster_name = var.cluster_name 84 | cluster_endpoint = var.cluster_endpoint 85 | machine_secrets = talos_machine_secrets.talos.machine_secrets 86 | machine_type = "controlplane" 87 | talos_version = "v${var.talos_version}" 88 | kubernetes_version = var.kubernetes_version 89 | examples = false 90 | docs = false 91 | config_patches = [ 92 | yamlencode(local.common_machine_config), 93 | yamlencode({ 94 | machine = { 95 | network = { 96 | interfaces = [ 97 | # see https://www.talos.dev/v1.8/talos-guides/network/vip/ 98 | { 99 | interface = "eth0" 100 | vip = { 101 | ip = var.cluster_vip 102 | } 103 | } 104 | ] 105 | } 106 | } 107 | }), 108 | yamlencode({ 109 | cluster = { 110 | inlineManifests = concat([ 111 | { 112 | name = "spin" 113 | contents = <<-EOF 114 | apiVersion: node.k8s.io/v1 115 | kind: RuntimeClass 116 | metadata: 117 | name: wasmtime-spin-v2 118 | handler: spin 119 | EOF 120 | }, 121 | { 122 | name = "cilium" 123 | contents = join("---\n", [ 124 | data.helm_template.cilium.manifest, 125 | "# Source cilium.tf\n${local.cilium_external_lb_manifest}", 126 | ]) 127 | }, 128 | { 129 | name = "cert-manager" 130 | contents = join("---\n", [ 131 | yamlencode({ 132 | apiVersion = "v1" 133 | kind = "Namespace" 134 | metadata = { 135 | name = "cert-manager" 136 | } 137 | }), 138 | data.helm_template.cert_manager.manifest, 139 | "# Source cert-manager.tf\n${local.cert_manager_ingress_ca_manifest}", 140 | ]) 141 | }, 142 | { 143 | name = "trust-manager" 144 | contents = data.helm_template.trust_manager.manifest 145 | }, 146 | { 147 | name = "reloader" 148 | contents = data.helm_template.reloader.manifest 149 | } 150 | ], var.argocd_enabled ? [ 151 | { 152 | name = "argocd" 153 | contents = join("---\n", [ 154 | yamlencode({ 155 | apiVersion = "v1" 156 | kind = "Namespace" 157 | metadata = { 158 | name = local.argocd_namespace 159 | } 160 | }), 161 | data.helm_template.argocd.manifest, 162 | "# Source argocd.tf\n${local.argocd_manifest}", 163 | ]) 164 | } 165 | ] : []) 166 | } 167 | }), 168 | ] 169 | 170 | } 171 | 172 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/data-sources/machine_configuration 173 | data "talos_machine_configuration" "worker" { 174 | cluster_name = var.cluster_name 175 | cluster_endpoint = var.cluster_endpoint 176 | machine_secrets = talos_machine_secrets.talos.machine_secrets 177 | machine_type = "worker" 178 | talos_version = "v${var.talos_version}" 179 | kubernetes_version = var.kubernetes_version 180 | examples = false 181 | docs = false 182 | config_patches = [ 183 | yamlencode(local.common_machine_config), 184 | ] 185 | } 186 | 187 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/data-sources/client_configuration 188 | data "talos_client_configuration" "talos" { 189 | cluster_name = var.cluster_name 190 | client_configuration = talos_machine_secrets.talos.client_configuration 191 | endpoints = [for node in local.controller_nodes : node.address] 192 | } 193 | 194 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/resources/cluster_kubeconfig 195 | resource "talos_cluster_kubeconfig" "talos" { 196 | client_configuration = talos_machine_secrets.talos.client_configuration 197 | endpoint = local.controller_nodes[0].address 198 | node = local.controller_nodes[0].address 199 | depends_on = [ 200 | talos_machine_bootstrap.talos, 201 | ] 202 | } 203 | 204 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/resources/machine_configuration_apply 205 | resource "talos_machine_configuration_apply" "controller" { 206 | count = var.controller_count 207 | client_configuration = talos_machine_secrets.talos.client_configuration 208 | machine_configuration_input = data.talos_machine_configuration.controller.machine_configuration 209 | endpoint = local.controller_nodes[count.index].address 210 | node = local.controller_nodes[count.index].address 211 | config_patches = [ 212 | yamlencode({ 213 | machine = { 214 | network = { 215 | hostname = local.controller_nodes[count.index].name 216 | nameservers = var.dns_serveurs 217 | } 218 | time = { 219 | servers = var.ntp_serveurs 220 | } 221 | } 222 | }), 223 | ] 224 | depends_on = [ 225 | proxmox_virtual_environment_vm.controller, 226 | ] 227 | } 228 | 229 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/resources/machine_configuration_apply 230 | resource "talos_machine_configuration_apply" "worker" { 231 | count = var.worker_count 232 | client_configuration = talos_machine_secrets.talos.client_configuration 233 | machine_configuration_input = data.talos_machine_configuration.worker.machine_configuration 234 | endpoint = local.worker_nodes[count.index].address 235 | node = local.worker_nodes[count.index].address 236 | config_patches = [ 237 | yamlencode({ 238 | machine = { 239 | network = { 240 | hostname = local.worker_nodes[count.index].name 241 | nameservers = var.dns_serveurs 242 | } 243 | time = { 244 | servers = var.ntp_serveurs 245 | } 246 | sysctls = { 247 | "net.ipv6.conf.all.disable_ipv6" = "1" 248 | "net.ipv6.conf.default.disable_ipv6" = "1" 249 | "net.ipv6.conf.lo.disable_ipv6" = "1" 250 | } 251 | } 252 | }), 253 | ] 254 | depends_on = [ 255 | proxmox_virtual_environment_vm.worker, 256 | ] 257 | } 258 | 259 | // see https://registry.terraform.io/providers/siderolabs/talos/0.10.0/docs/resources/machine_bootstrap 260 | resource "talos_machine_bootstrap" "talos" { 261 | client_configuration = talos_machine_secrets.talos.client_configuration 262 | endpoint = local.controller_nodes[0].address 263 | node = local.controller_nodes[0].address 264 | depends_on = [ 265 | talos_machine_configuration_apply.controller, 266 | ] 267 | } 268 | -------------------------------------------------------------------------------- /hack/linstor-backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # =================================================================== 4 | # Script 1: Backup de volumes LINSTOR via clonage (compatible LVM) 5 | # =================================================================== 6 | 7 | #!/bin/bash 8 | # linstor-backup-clone.sh 9 | 10 | set -e 11 | 12 | SCRIPT_NAME="$(basename "$0")" 13 | NAME SPACE="piraeus-datastore" 14 | BACKUP_PREFIX="backup-$(date +%m%d-%H%M)" 15 | 16 | usage() { 17 | cat << EOF 18 | Usage: $SCRIPT_NAME [OPTIONS] RESOURCE_NAME 19 | 20 | Crée une sauvegarde d'une ressource LINSTOR via clonage (compatible LVM) 21 | 22 | OPTIONS: 23 | -n, --namespace NAMESPACE Namespace du piraeus-operator (défaut: $NAMESPACE) 24 | -p, --prefix PREFIX Préfixe pour le backup (défaut: $BACKUP_PREFIX) 25 | -d, --description DESC Description du backup 26 | -t, --temporary Crée un clone temporaire (sera supprimé) 27 | -k, --keep-clone Garde le clone après export 28 | -o, --output-dir DIR Répertoire de sortie pour l'export (défaut: /tmp/linstor-backups) 29 | -h, --help Affiche cette aide 30 | 31 | EXEMPLES: 32 | $SCRIPT_NAME my-pvc 33 | $SCRIPT_NAME -d "Backup avant mise à jour" -o /backups my-database-vol 34 | $SCRIPT_NAME -t -k my-vol # Clone temporaire gardé 35 | EOF 36 | } 37 | 38 | # Générer un nom de backup court 39 | generate_backup_name() { 40 | local resource_name="$1" 41 | local prefix="$2" 42 | 43 | # Utiliser un hash pour les noms très longs 44 | if [ ${#resource_name} -gt 30 ]; then 45 | local resource_hash=$(echo "$resource_name" | sha256sum | cut -c1-8) 46 | echo "${prefix}-${resource_hash}" 47 | else 48 | echo "${prefix}-${resource_name}" 49 | fi 50 | } 51 | 52 | # Créer un clone de la ressource 53 | create_clone() { 54 | local source_resource="$1" 55 | local clone_name="$2" 56 | local description="$3" 57 | 58 | echo "🔄 Création du clone '$clone_name' de la ressource '$source_resource'..." 59 | 60 | # Obtenir les informations de la ressource source (sans --parsable) 61 | echo "📋 Récupération des informations de la ressource source..." 62 | local resource_info 63 | resource_info=$(kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 64 | linstor resource list -r "$source_resource") 65 | 66 | if [ -z "$resource_info" ]; then 67 | echo "❌ Ressource '$source_resource' introuvable" 68 | exit 1 69 | fi 70 | 71 | # Vérifier que la ressource existe en cherchant son nom dans la sortie 72 | if ! echo "$resource_info" | grep -q "$source_resource"; then 73 | echo "❌ Ressource '$source_resource' introuvable" 74 | exit 1 75 | fi 76 | 77 | # Créer la définition de ressource pour le clone 78 | echo "📝 Création de la définition de ressource clone..." 79 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 80 | linstor resource-definition create "$clone_name" 81 | 82 | # Copier les volumes (sans --parsable) 83 | echo "💾 Copie des volumes..." 84 | local volumes_output 85 | volumes_output=$(kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 86 | linstor volume-definition list -r "$source_resource") 87 | 88 | # Parser la sortie manuellement (adapter selon le format de votre version) 89 | # Cette partie doit être adaptée selon la sortie exacte de votre commande 90 | local volume_ids 91 | volume_ids=$(echo "$volumes_output" | grep -E "^\s*[0-9]+" | awk '{print $1}' | sort -u) 92 | 93 | for vol_id in $volume_ids; do 94 | # Obtenir la taille du volume 95 | local size_info 96 | size_info=$(echo "$volumes_output" | grep -E "^\s*${vol_id}\s+" | head -n1) 97 | local size_kb=$(echo "$size_info" | awk '{for(i=1;i<=NF;i++) if($i ~ /[0-9]+[kKmMgGtT][bB]?$/) print $i}' | head -n1) 98 | 99 | if [ -z "$size_kb" ]; then 100 | # Fallback: essayer d'obtenir la taille autrement 101 | size_kb="1GiB" # Taille par défaut, à ajuster 102 | fi 103 | 104 | # Créer la définition de volume pour le clone 105 | echo " Création du volume $vol_id avec taille $size_kb" 106 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 107 | linstor volume-definition create "$clone_name" "$vol_id" "$size_kb" 108 | done 109 | 110 | # Déployer le clone sur les mêmes nœuds que la source 111 | echo "🚀 Déploiement du clone..." 112 | local nodes_output 113 | nodes_output=$(kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 114 | linstor resource list -r "$source_resource") 115 | 116 | # Parser les nœuds manuellement 117 | local nodes 118 | nodes=$(echo "$nodes_output" | grep "$source_resource" | awk '{print $2}' | sort -u) 119 | 120 | for node in $nodes; do 121 | if [ -n "$node" ] && [ "$node" != "Node" ]; then # Éviter les en-têtes 122 | echo " Déploiement sur le nœud: $node" 123 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 124 | linstor resource create "$clone_name" "$node" 125 | fi 126 | done 127 | 128 | # Ajouter des propriétés au clone 129 | if [ -n "$description" ]; then 130 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 131 | linstor resource-definition set-property "$clone_name" Description "$description" 132 | fi 133 | 134 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 135 | linstor resource-definition set-property "$clone_name" BackupSource "$source_resource" 136 | 137 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 138 | linstor resource-definition set-property "$clone_name" BackupDate "$(date -Iseconds)" 139 | 140 | echo "✅ Clone '$clone_name' créé avec succès !" 141 | } 142 | 143 | # Exporter les données du clone 144 | export_clone_data() { 145 | local clone_name="$1" 146 | local output_dir="$2" 147 | local keep_clone="$3" 148 | 149 | echo "📤 Export des données du clone '$clone_name'..." 150 | 151 | # Créer le répertoire de sortie 152 | mkdir -p "$output_dir" 153 | 154 | # Trouver le device du clone sur un nœud (sans --parsable) 155 | local resource_output 156 | resource_output=$(kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 157 | linstor resource list -r "$clone_name") 158 | 159 | local node_name 160 | node_name=$(echo "$resource_output" | grep "$clone_name" | head -n1 | awk '{print $2}') 161 | 162 | if [ -z "$node_name" ] || [ "$node_name" = "Node" ]; then 163 | echo "❌ Impossible de trouver un nœud pour le clone" 164 | return 1 165 | fi 166 | 167 | echo "📍 Export depuis le nœud: $node_name" 168 | 169 | # Obtenir le chemin du device (sans --parsable) 170 | local volume_output 171 | volume_output=$(kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 172 | linstor resource list-volumes -r "$clone_name" -n "$node_name") 173 | 174 | local device_path 175 | device_path=$(echo "$volume_output" | grep "/dev/" | awk '{for(i=1;i<=NF;i++) if($i ~ /^\/dev\//) print $i}' | head -n1) 176 | 177 | if [ -n "$device_path" ]; then 178 | local backup_file="$output_dir/${clone_name}-$(date +%Y%m%d-%H%M%S).img" 179 | 180 | echo "💾 Création de l'image disque: $backup_file" 181 | echo "⚠️ Cette opération peut prendre du temps selon la taille du volume..." 182 | 183 | # Créer un Job Kubernetes pour faire le backup 184 | echo "📋 Création d'un Job Kubernetes pour l'export..." 185 | 186 | cat << EOF | kubectl apply -f - 187 | apiVersion: batch/v1 188 | kind: Job 189 | metadata: 190 | name: linstor-backup-export-$(date +%s) 191 | namespace: $NAMESPACE 192 | spec: 193 | template: 194 | spec: 195 | nodeName: $node_name 196 | containers: 197 | - name: backup-exporter 198 | image: alpine:latest 199 | command: ["/bin/sh"] 200 | args: 201 | - -c 202 | - | 203 | apk add --no-cache pv 204 | echo "Démarrage de l'export de $device_path vers $backup_file" 205 | dd if=$device_path bs=1M conv=sparse | pv > $backup_file 206 | echo "Export terminé: $backup_file" 207 | volumeMounts: 208 | - name: host-dev 209 | mountPath: /dev 210 | - name: backup-storage 211 | mountPath: $output_dir 212 | securityContext: 213 | privileged: true 214 | volumes: 215 | - name: host-dev 216 | hostPath: 217 | path: /dev 218 | - name: backup-storage 219 | hostPath: 220 | path: $output_dir 221 | restartPolicy: Never 222 | backoffLimit: 3 223 | EOF 224 | 225 | echo "✅ Job de backup créé. Surveillez avec: kubectl logs -n $NAMESPACE job/linstor-backup-export-*" 226 | 227 | else 228 | echo "❌ Impossible de trouver le chemin du device pour le clone" 229 | fi 230 | 231 | # Nettoyer le clone si demandé 232 | if [ "$keep_clone" != "true" ]; then 233 | echo "🗑️ Suppression du clone temporaire..." 234 | kubectl exec -n "$NAMESPACE" deployment/linstor-controller -- \ 235 | linstor resource-definition delete "$clone_name" 236 | echo "✅ Clone temporaire supprimé" 237 | else 238 | echo "📌 Clone conservé: $clone_name" 239 | fi 240 | } 241 | 242 | # Parsing des arguments 243 | RESOURCE_NAME="" 244 | DESCRIPTION="" 245 | TEMPORARY="false" 246 | KEEP_CLONE="false" 247 | OUTPUT_DIR="/tmp/linstor-backups" 248 | 249 | while [[ $# -gt 0 ]]; do 250 | case $1 in 251 | -n|--namespace) 252 | NAMESPACE="$2" 253 | shift 2 254 | ;; 255 | -p|--prefix) 256 | BACKUP_PREFIX="$2" 257 | shift 2 258 | ;; 259 | -d|--description) 260 | DESCRIPTION="$2" 261 | shift 2 262 | ;; 263 | -t|--temporary) 264 | TEMPORARY="true" 265 | shift 266 | ;; 267 | -k|--keep-clone) 268 | KEEP_CLONE="true" 269 | shift 270 | ;; 271 | -o|--output-dir) 272 | OUTPUT_DIR="$2" 273 | shift 2 274 | ;; 275 | -h|--help) 276 | usage 277 | exit 0 278 | ;; 279 | -*) 280 | echo "Option inconnue: $1" >&2 281 | usage >&2 282 | exit 1 283 | ;; 284 | *) 285 | if [ -z "$RESOURCE_NAME" ]; then 286 | RESOURCE_NAME="$1" 287 | else 288 | echo "Trop d'arguments" >&2 289 | usage >&2 290 | exit 1 291 | fi 292 | shift 293 | ;; 294 | esac 295 | done 296 | 297 | if [ -z "$RESOURCE_NAME" ]; then 298 | echo "❌ Nom de ressource requis" >&2 299 | usage >&2 300 | exit 1 301 | fi 302 | 303 | CLONE_NAME=$(generate_backup_name "$RESOURCE_NAME" "$BACKUP_PREFIX") 304 | 305 | echo "🚀 Démarrage du backup LINSTOR via clonage" 306 | echo " Ressource source: $RESOURCE_NAME" 307 | echo " Clone: $CLONE_NAME" 308 | echo " Namespace: $NAMESPACE" 309 | echo " Répertoire de sortie: $OUTPUT_DIR" 310 | echo "" 311 | 312 | create_clone "$RESOURCE_NAME" "$CLONE_NAME" "$DESCRIPTION" 313 | export_clone_data "$CLONE_NAME" "$OUTPUT_DIR" "$KEEP_CLONE" 314 | 315 | echo "" 316 | echo "✅ Backup terminé !" 317 | if [ "$KEEP_CLONE" = "true" ]; then 318 | echo "📌 Clone disponible: $CLONE_NAME" 319 | fi 320 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------