forked from NationTech/harmony
save experimentation
This commit is contained in:
9
DEVELOP.md
Normal file
9
DEVELOP.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# teste scp
|
||||
|
||||
```
|
||||
# génère un fichier de 1024mb
|
||||
|
||||
dd if=/dev/urandom of=testfile bs=10M count=10240
|
||||
```
|
||||
|
||||
|
||||
185
examples/okd_installation/DEVELOP.md
Normal file
185
examples/okd_installation/DEVELOP.md
Normal file
@@ -0,0 +1,185 @@
|
||||
## opnsense
|
||||
|
||||
### fonctionnalité
|
||||
|
||||
- ajout de clef ssh
|
||||
|
||||
|
||||
## prérequis environnement d'exécution harmony
|
||||
|
||||
- git-lfs est installé et les gros fichiers ont été téléchargés localement
|
||||
|
||||
|
||||
|
||||
## prérequis physique
|
||||
|
||||
- les disques dur de toutes les nodes doivent être effacés (dd if=/dev/zero of=/dev/... ou
|
||||
|
||||
|
||||
## prérequis opnsense
|
||||
|
||||
|
||||
|
||||
## procédure
|
||||
|
||||
### Actuelle
|
||||
|
||||
- mettre en place le setup physique
|
||||
- mettre en place le setup opnsense
|
||||
- initialisation opnsense et démarrage de l'agent inventaire (OKDipxeScore et OKDSetup01InventoryScore)
|
||||
- mise en place de la node bootstrap (OKDSetup01InventoryScore)
|
||||
|
||||
### idéale
|
||||
|
||||
- setup physique
|
||||
- setup opnsense (avec topology harmony)
|
||||
-
|
||||
|
||||
|
||||
## OKDipxeScore
|
||||
|
||||
- Améliore visibilité de l'erreur si les packages ne sont pas à jour. En particulier, certains packages ne cont pas accessible lorsque le registre n'est pas à jour (os-caddy, haproxy, etc)
|
||||
|
||||
## OKDSetup01InventoryScore
|
||||
## OKDSetup02BootstrapScore
|
||||
|
||||
> [INFO ] [Bootstrap] Rebooting bootstrap node via SSH
|
||||
> ? Now reboot the bootstrap node so it picks up its pxe boot file. Press enter when ready.
|
||||
|
||||
|
||||
- on devrait pas assigner le role à la node après que le pxe boot soit ok?
|
||||
|
||||
|
||||
|
||||
génère localement (.data/okd) tout le nécessaire à installer okd 1 node (config, certificat, exécutables, etc)
|
||||
|
||||
|
||||
|
||||
## OKDSetup03ControlPlaneScore
|
||||
## OKDSetupPersistNetworkBondScore
|
||||
## OKDSetup04WorkersScore
|
||||
## OKDSetup05SanityCheckScore
|
||||
## OKDSetup06InstallationReportScore
|
||||
|
||||
## Conception
|
||||
|
||||
|
||||
|
||||
|
||||
## Ce qu'il manque / bug
|
||||
|
||||
- le webgui de opensense n'est plus utilisable après la mise en place de ha proxy. Il faut changer son port à 8443
|
||||
|
||||
- création du sqlite
|
||||
- dépendance sur git-lfs. sinon, ne récupère pas correctement les gros fichiers
|
||||
- le plugin os-caddy doit être installé manuellement
|
||||
|
||||
- réexécution de OKDipxeScore efface le fichier authorized_keys. les cles ssh ajouter par l'utilisateur sont détruite
|
||||
- Si l'on change les fichiers dans data, une réexécution de OKDipxeScore ne les mets pas à jour
|
||||
|
||||
### OKDSetup01InventoryScore ne termine pas
|
||||
|
||||
- l'agent inventaire est lancé en background
|
||||
- ceci empêche de terminer le score
|
||||
|
||||
### fichiers data manquants
|
||||
|
||||
- ce qui arrive: plante avec erreur non explicite
|
||||
- raison: fichier ./data/pxe/okd/tftpboot/
|
||||
- composante affectée: opnsense_config::config::shell::ssh.
|
||||
|
||||
- mitigation: Afficher un meilleur message
|
||||
- solutions:
|
||||
- passer le path vers data en paramètre
|
||||
- documenter
|
||||
|
||||
### chargement des fichiers requis
|
||||
|
||||
- Execute the copy : `scp -r data/pxe/okd/http_files/* root@192.168.1.1:/usr/local/http/` and confirm when done to continue
|
||||
|
||||
> [INFO ] ✅ Http Server running and serving files from folder No
|
||||
> ne and content for ./boot.ipxe,./inventory.kickstart,./fallback
|
||||
> .ipxe,./cluster_ssh_key.pub
|
||||
> ? Execute the copy : `scp -r data/pxe/okd/http_files/* root@192
|
||||
> .168.1.1:/usr/local/http/` and confirm when done to continue
|
||||
|
||||
- pas idempotent, redemande à toutes les exécutions
|
||||
|
||||
|
||||
|
||||
### Configurer les hostnames dans opnsense
|
||||
|
||||
> [INFO ] Setting up base DNS config for OKD
|
||||
> ? Set hostnames manually in your opnsense dnsmasq config :
|
||||
> *.apps.demo.harmony.mcd -> 192.168.1.1
|
||||
> api.demo.harmony.mcd -> 192.168.1.1
|
||||
> api-int.demo.harmony.mcd -> 192.168.1.1
|
||||
> When you can dig them, confirm to continue.
|
||||
|
||||
### Base de donnée sqlite
|
||||
|
||||
> [ERROR] ⚠️ Interpret error : Could not connect to the database: error returned from database: (code:
|
||||
> 14) unable to open database fi
|
||||
|
||||
voir: https://git.nationtech.io/NationTech/harmony/src/branch/feat/rebuild_inventory/empty_database.sqlite
|
||||
|
||||
- initialiser automatiquement la bd mysql
|
||||
- vérifier aviser si la bd n'est pas trouvée ou si elle n'est pas lisible ou mauvais schema
|
||||
|
||||
## À améliorer
|
||||
|
||||
- inventory agent: meilleur gestion des nodes et de leur role (exemple, pas possible de voir quels sont les nodes et leur rôle)
|
||||
- pour boot sur node bootsratp , l user est core et non root
|
||||
- clarifier le 'nom du cluster' (arg 2 de location) ve secret namespace
|
||||
|
||||
- meilleur manière de sélectionner la node pour bootstrap
|
||||
- comment vérifier que OKDSetup01InventoryScore est terminé avec succès?
|
||||
- Avant d'installer os, vérifier que les disques sont bien effacés et aviser l'utilisateur dans le cas contraire
|
||||
- où trouver le pullsecret de redhat? https://console.redhat.com/openshift/install/pull-secret
|
||||
- documenter le format de la clef Redhat: pull_secret: <stringified key>
|
||||
- lorsque harmony lance une commande et que ça plante, afficher la commande qui a été lancée pour que l'on puisse reproduire manuellement
|
||||
|
||||
### Mieux informer l'utilisateur
|
||||
|
||||
> [INFO ] Launching discovery agent, make sure that your nodes ar
|
||||
> e successfully PXE booted and running inventory agent. They sho
|
||||
> uld answer on `http://<node_ip>:8080/inventory`
|
||||
|
||||
- le message est pas évident et passe rapidement
|
||||
- il faut savoir que les nodes doivent être démarrés par pxe pour être identifier par harmony
|
||||
- fix rapide: demander à user de confirmer
|
||||
|
||||
### instruction sur le setup matériel
|
||||
|
||||
- inclure une documentation sur le setup matériel
|
||||
- avoir des prérequis et une check list
|
||||
|
||||
checklist:
|
||||
- spec min (...)
|
||||
- setup bios: no tmp, no secure boot,
|
||||
- effacer les disques durs
|
||||
|
||||
### score plan
|
||||
|
||||
- Le plus tôt possible, s'assurer (dans l'implémentation des scores) que l'exécution est possible. (score plan)
|
||||
- sinon fail fast (avant toute exécution
|
||||
|
||||
### prérequis opnsense
|
||||
|
||||
- opnsense fonctionnel et interfaces configurés
|
||||
- ssh actif et connectivité possible => credentials dans harmony secrets manager
|
||||
- update faits
|
||||
- port = 8443 (443 sera utilisé par HAProxy
|
||||
|
||||
|
||||
## PR
|
||||
|
||||
|
||||
## Questions
|
||||
|
||||
|
||||
- comment faire pour configurer opnsense (ssh ok, mans pas root, création d'utilisateur + role/permission)
|
||||
|
||||
|
||||
- wipefs
|
||||
- sgdisk
|
||||
@@ -1,4 +1,12 @@
|
||||
export HARMONY_SECRET_NAMESPACE=example-vms
|
||||
NAMESPACE=example-okd
|
||||
export HARMONY_SECRET_NAMESPACE=$NAMESPACE
|
||||
export HARMONY_SECRET_STORE=file
|
||||
export HARMONY_DATABASE_URL=sqlite://harmony_vms.sqlite RUST_LOG=info
|
||||
|
||||
|
||||
#export DB_PATH=$HOME/.local/share/instances/$NAMESPACE/db.sqlite
|
||||
#export HARMONY_DATABASE_URL=sqlite://$HOME/.local/share/instances/$NAMESPACE/db.sqlite
|
||||
export HARMONY_DATABASE_URL=sqlite://db.sqlite
|
||||
|
||||
export RUST_LOG=info
|
||||
#export RUST_LOG=debug,serde
|
||||
#export RUST_LOG=info,yaserde=debug
|
||||
|
||||
@@ -12,6 +12,7 @@ use harmony_secret::SecretManager;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// env_logger::init();
|
||||
let inventory = get_inventory();
|
||||
let topology = get_topology().await;
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use brocade::BrocadeOptions;
|
||||
use cidr::Ipv4Cidr;
|
||||
use harmony::{
|
||||
hardware::{Location, SwitchGroup},
|
||||
infra::{brocade::BrocadeSwitchClient, opnsense::OPNSenseManagementInterface},
|
||||
infra::{brocade::UnmanagedSwitch, opnsense::OPNSenseManagementInterface},
|
||||
inventory::Inventory,
|
||||
topology::{HAClusterTopology, LogicalHost, UnmanagedRouter},
|
||||
};
|
||||
@@ -30,17 +29,7 @@ pub async fn get_topology() -> HAClusterTopology {
|
||||
.await
|
||||
.expect("Failed to get credentials");
|
||||
|
||||
let switches: Vec<IpAddr> = vec![ip!("192.168.1.101")]; // TODO: Adjust me
|
||||
let brocade_options = Some(BrocadeOptions {
|
||||
dry_run: *harmony::config::DRY_RUN,
|
||||
..Default::default()
|
||||
});
|
||||
let switch_client = BrocadeSwitchClient::init(
|
||||
&switches,
|
||||
&switch_auth.username,
|
||||
&switch_auth.password,
|
||||
brocade_options,
|
||||
)
|
||||
let switch_client = UnmanagedSwitch::init()
|
||||
.await
|
||||
.expect("Failed to connect to switch");
|
||||
|
||||
|
||||
@@ -113,6 +113,37 @@ impl SwitchClient for BrocadeSwitchClient {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UnmanagedSwitch;
|
||||
|
||||
impl UnmanagedSwitch {
|
||||
pub async fn init( ) -> Result<Self, ()> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SwitchClient for UnmanagedSwitch {
|
||||
async fn setup(&self) -> Result<(), SwitchError> {
|
||||
todo!("unmanaged switch. Nothing to do.")
|
||||
}
|
||||
|
||||
async fn find_port(
|
||||
&self,
|
||||
mac_address: &MacAddress,
|
||||
) -> Result<Option<PortLocation>, SwitchError> {
|
||||
todo!("unmanaged switch. Nothing to do.")
|
||||
}
|
||||
|
||||
async fn configure_port_channel(
|
||||
&self,
|
||||
channel_name: &str,
|
||||
switch_ports: Vec<PortLocation>,
|
||||
) -> Result<u8, SwitchError> {
|
||||
todo!("unmanaged switch. Nothing to do.")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -272,7 +272,7 @@ impl OKDSetup02BootstrapInterpret {
|
||||
http_ip: &topology.http_server.get_ip().to_string(),
|
||||
scos_path: "scos", // TODO use some constant
|
||||
ignition_http_path: "okd_ignition_files", // TODO use proper variable
|
||||
installation_device: "/dev/sda",
|
||||
installation_device: "/dev/nvme0n1",
|
||||
ignition_file_name: "bootstrap.ign",
|
||||
}
|
||||
.to_string();
|
||||
|
||||
@@ -10,6 +10,7 @@ use std::io::Write;
|
||||
use std::sync::Mutex;
|
||||
|
||||
pub fn init() {
|
||||
info!{"configure logger"}
|
||||
configure_logger();
|
||||
handle_events();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ pub struct LocalFileSecretStore;
|
||||
impl LocalFileSecretStore {
|
||||
/// Helper to consistently generate the secret file path.
|
||||
fn get_file_path(base_dir: &Path, ns: &str, key: &str) -> PathBuf {
|
||||
info!{
|
||||
"LOCAL_STORE: Getting key '{key}' from namespace '{ns}'"
|
||||
};
|
||||
base_dir.join(format!("{ns}_{key}.json"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ pub struct System {
|
||||
pub maximumfrags: Option<MaybeString>,
|
||||
pub aliasesresolveinterval: Option<MaybeString>,
|
||||
pub maximumtableentries: Option<MaybeString>,
|
||||
pub language: String,
|
||||
pub language: Option<String>,
|
||||
pub dnsserver: Option<MaybeString>,
|
||||
pub dns1gw: Option<String>,
|
||||
pub dns2gw: Option<String>,
|
||||
@@ -1229,6 +1229,7 @@ pub struct Host {
|
||||
pub ttl: Option<MaybeString>,
|
||||
pub server: String,
|
||||
pub description: Option<String>,
|
||||
pub txtdata: Option<String>,
|
||||
}
|
||||
|
||||
impl Host {
|
||||
@@ -1244,6 +1245,7 @@ impl Host {
|
||||
ttl: Some(MaybeString::default()),
|
||||
mx: MaybeString::default(),
|
||||
description: None,
|
||||
txtdata: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user