Skip to content

Commit

Permalink
Established default agent namespace - fleet-addon-agent
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
  • Loading branch information
Danil-Grigorev committed Jun 11, 2024
1 parent f34f0df commit a3315da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion config/crds/fleet-addon-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spec:
description: Cluster controller settings
nullable: true
properties:
agent_namespace:
description: Namespace selection for the fleet agent
nullable: true
type: string
enabled:
description: |-
Enable Cluster config funtionality.
Expand All @@ -33,7 +37,7 @@ spec:
nullable: true
type: boolean
naming:
description: Specifies a name suffix for the fleet cluster
description: Naming settings for the fleet cluster
properties:
prefix:
description: Specify a prefix for the Cluster name, applied to created Fleet cluster
Expand Down
6 changes: 5 additions & 1 deletion src/api/fleet_addon_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ pub struct ClusterConfig {
/// Setting to disable setting owner references on the created resources
pub set_owner_references: Option<bool>,

/// Specifies a name suffix for the fleet cluster
/// Naming settings for the fleet cluster
pub naming: NamingStrategy,

/// Namespace selection for the fleet agent
pub agent_namespace: Option<String>,

#[cfg(feature = "agent-initiated")]
/// Prepare initial cluster for agent initiated connection
pub agent_initiated: Option<bool>,
Expand All @@ -85,6 +88,7 @@ impl Default for ClusterConfig {
Self {
set_owner_references: Some(true),
naming: Default::default(),
agent_namespace: "fleet-addon-agent".to_string().into(),
enabled: Some(true),
#[cfg(feature = "agent-initiated")]
agent_initiated: Some(true),
Expand Down
3 changes: 3 additions & 0 deletions src/controllers/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,19 @@ impl Cluster {
spec: match config.agent_initiated {
Some(true) => fleet_cluster::ClusterSpec {
client_id: Some(Alphanumeric.sample_string(&mut rand::thread_rng(), 64)),
agent_namespace: config.agent_namespace,
..Default::default()
},
None | Some(false) => fleet_cluster::ClusterSpec {
kube_config_secret: Some(format!("{}-kubeconfig", self.name_any())),
agent_namespace: config.agent_namespace,
..Default::default()
},
},
#[cfg(not(feature = "agent-initiated"))]
spec: fleet_cluster::ClusterSpec {
kube_config_secret: Some(format!("{}-kubeconfig", self.name_any())),
agent_namespace: config.agent_namespace,
..Default::default()
},
status: Default::default(),
Expand Down

0 comments on commit a3315da

Please sign in to comment.