Skip to content

Commit 69f825d

Browse files
adwk67razvan
andauthored
feat: Git sync - add first class support for CAs (#903)
* bump gitsync to v2, adapt test to use ca cert * added a docs note * changelog * switch to tls field * fixed branch ref * updated docs * bump op-rs * minor cleanup * use non-privileged nginx as needed for openshift * remove schemars workarounds * bump op-rs to 0.110.1 * updated changelog * removed duplicate comment * Update docs/modules/nifi/pages/usage_guide/custom-components.adoc Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> --------- Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
1 parent 940f265 commit 69f825d

15 files changed

Lines changed: 1193 additions & 878 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66

77
### Added
88

9+
- Support for passing CAs to GitSync ([#903]).
910
- Added support for NiFi `2.9.0` ([#922]).
1011

1112
### Changed
@@ -15,6 +16,7 @@ All notable changes to this project will be documented in this file.
1516
Previously, arbitrary keys were silently accepted but ignored ([#921]).
1617
- Bump `stackable-operator` to 0.110.1 and `kube` to 3.1.0 ([#921]).
1718

19+
[#903]: https://github.com/stackabletech/nifi-operator/pull/903
1820
[#916]: https://github.com/stackabletech/nifi-operator/pull/916
1921
[#921]: https://github.com/stackabletech/nifi-operator/pull/921
2022
[#922]: https://github.com/stackabletech/nifi-operator/pull/922

Cargo.lock

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 61 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/modules/nifi/pages/usage_guide/custom-components.adoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,19 @@ spec:
5858
wait: 10s # <6>
5959
credentialsSecret: git-credentials # <7>
6060
gitSyncConf: # <8>
61-
--git-config: http.sslCAInfo:/tmp/ca-cert/ca.crt
62-
- repo: https://example.com/git/other-nifi-components # <9>
61+
--git-config: pull.rebase=true # <9>
62+
tls:
63+
verification:
64+
server:
65+
caCert:
66+
secretClass: git-ca-cert # <10>
67+
- repo: https://example.com/git/other-nifi-components # <11>
6368
nodes:
6469
config:
6570
logging:
6671
enableVectorAgent: true
6772
containers:
68-
git-sync: # <10>
73+
git-sync: # <12>
6974
console:
7075
level: INFO
7176
file:
@@ -94,8 +99,14 @@ data:
9499
The `password` field can either be an actual password (not recommended) or a GitHub token, as described in the {git-sync-docs}[git-sync documentation].
95100
<8> A map of optional configuration settings that are listed in the {git-sync-docs}[git-sync documentation]. +
96101
These settings are not verified.
97-
<9> Multiple repositories can be defined. Only the `repo` field is mandatory.
98-
<10> Logging can be configured as described in xref:concepts:logging.adoc[].
102+
<9> Valid `git-config` settings can be passed here N.B. a warning will be triggered if both `http.sslCAInfo` is defined here and the field `caCertSecretName` is specified (as it maps onto the same config setting).
103+
<10> Optional name of a SecretClass for certificate authorities. These CAs will verify the git server's certificate when running git sync operations.
104+
The associated secret must have a key named `ca.crt` whose value is the PEM-encoded certificate bundle.
105+
If this field is set to `webPki: {}` or is omitted altogether, then no changes will be made to the gitsync command and it will default to presenting no certificate to the backend.
106+
Omitting this field is non-breaking behaviour and as such it does *not* set `http.sslverify` to `false` as disabling security checks should be a last resort and not something activated by default.
107+
This can still be achieved by passing `--git-config: http.sslverify=false` explicitly.
108+
<11> Multiple repositories can be defined. Only the `repo` field is mandatory.
109+
<12> Logging can be configured as described in xref:concepts:logging.adoc[].
99110
As git-sync is a command-line tool, just its output is logged and no fine-grained log configuration is possible.
100111
All git-sync containers are configured via the one `git-sync` field.
101112

extra/crds.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,34 @@ spec:
181181
182182
Since git-sync v4.x.x this field is mapped to the flag `--ref`.
183183
type: string
184-
credentialsSecret:
184+
credentials:
185185
description: An optional secret used for git access.
186186
nullable: true
187-
type: string
187+
oneOf:
188+
- required:
189+
- basicAuthSecretName
190+
- required:
191+
- sshPrivateKeySecretName
192+
properties:
193+
basicAuthSecretName:
194+
description: |-
195+
The name of the Secret used to access the repository via Basic Authentication if it is not public.
196+
197+
The referenced Secret must include two fields: `user` and `password`.
198+
The `password` field can either be an actual password (not recommended) or a GitHub token,
199+
as described in the git-sync [documentation].
200+
201+
[documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
202+
type: string
203+
sshPrivateKeySecretName:
204+
description: |-
205+
The name of the Secret used for SSH access to the repository.
206+
207+
The referenced Secret must include two fields: `key` and `knownHosts`.
208+
209+
[documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
210+
type: string
211+
type: object
188212
depth:
189213
default: 1
190214
description: The depth of syncing, i.e. the number of commits to clone; defaults to 1.

nix/sources.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/operator-binary/src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn build_nifi_properties(
157157
auth_config: &NifiAuthenticationConfig,
158158
overrides: BTreeMap<String, String>,
159159
product_version: &str,
160-
git_sync_resources: &git_sync::v1alpha1::GitSyncResources,
160+
git_sync_resources: &git_sync::v1alpha2::GitSyncResources,
161161
) -> Result<String, Error> {
162162
// TODO: Remove once we dropped support for all NiFi 1.x versions
163163
let is_nifi_1 = product_version.starts_with("1.");

rust/operator-binary/src/controller.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub enum Error {
230230
FailedToResolveConfig { source: crate::crd::Error },
231231

232232
#[snafu(display("invalid git-sync specification"))]
233-
InvalidGitSyncSpec { source: git_sync::v1alpha1::Error },
233+
InvalidGitSyncSpec { source: git_sync::v1alpha2::Error },
234234

235235
#[snafu(display("vector agent is enabled but vector aggregator ConfigMap is missing"))]
236236
VectorAggregatorConfigMapMissing,
@@ -493,7 +493,7 @@ pub async fn reconcile_nifi(
493493
.merged_config(&NifiRole::Node, rolegroup_name)
494494
.context(FailedToResolveConfigSnafu)?;
495495

496-
let git_sync_resources = git_sync::v1alpha1::GitSyncResources::new(
496+
let git_sync_resources = git_sync::v1alpha2::GitSyncResources::new(
497497
&nifi.spec.cluster_config.custom_components_git_sync,
498498
&resolved_product_image,
499499
&env_vars_from_rolegroup_config(rolegroup_config),
@@ -724,7 +724,7 @@ async fn build_node_rolegroup_config_map(
724724
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
725725
merged_config: &NifiConfig,
726726
proxy_hosts: &str,
727-
git_sync_resources: &git_sync::v1alpha1::GitSyncResources,
727+
git_sync_resources: &git_sync::v1alpha2::GitSyncResources,
728728
) -> Result<ConfigMap> {
729729
tracing::debug!("building rolegroup configmaps");
730730

@@ -851,7 +851,7 @@ async fn build_node_rolegroup_statefulset(
851851
rolling_update_supported: bool,
852852
replicas: Option<i32>,
853853
service_account_name: &str,
854-
git_sync_resources: &git_sync::v1alpha1::GitSyncResources,
854+
git_sync_resources: &git_sync::v1alpha2::GitSyncResources,
855855
) -> Result<StatefulSet> {
856856
tracing::debug!("Building statefulset");
857857
let role_group = role.role_groups.get(&rolegroup_ref.role_group);
@@ -1238,6 +1238,9 @@ async fn build_node_rolegroup_statefulset(
12381238
pod_builder
12391239
.add_volumes(git_sync_resources.git_content_volumes.to_owned())
12401240
.context(AddVolumeSnafu)?;
1241+
pod_builder
1242+
.add_volumes(git_sync_resources.git_ca_cert_volumes.to_owned())
1243+
.context(AddVolumeSnafu)?;
12411244

12421245
if let Some(ContainerLogConfig {
12431246
choice:

rust/operator-binary/src/crd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub mod versioned {
159159
/// Learn more in the documentation for
160160
/// [Loading custom components](DOCS_BASE_URL_PLACEHOLDER/nifi/usage_guide/custom-components.html#git_sync).
161161
#[serde(default)]
162-
pub custom_components_git_sync: Vec<git_sync::v1alpha1::GitSync>,
162+
pub custom_components_git_sync: Vec<git_sync::v1alpha2::GitSync>,
163163

164164
/// Extra volumes similar to `.spec.volumes` on a Pod to mount into every container, this can be useful to for
165165
/// example make client certificates, keytabs or similar things available to processors. These volumes will be

0 commit comments

Comments
 (0)