Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ta update configs to enable mtls #3015

Open
wants to merge 93 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
69b4c63
Initial commit
ItielOlenick May 13, 2024
684afbd
Added Cert Manager CRDs & RBAC validation and management
ItielOlenick Jun 1, 2024
50d568a
Added relevant resources and started adding tests
ItielOlenick Jun 5, 2024
61ba6fc
Bump github.com/gin-gonic/gin from 1.9.1 to 1.10.0 (#2953)
dependabot[bot] May 13, 2024
f67c7d1
Bump github.com/prometheus/prometheus in the prometheus group (#2951)
dependabot[bot] May 13, 2024
ef3e6a4
Support for collector readinessProbe (#2944)
janario May 13, 2024
62484ae
Bump github.com/docker/docker (#2954)
dependabot[bot] May 13, 2024
801ca16
Added new Log Enconder Config (#2927)
yuriolisa May 13, 2024
dfc7882
[chore] move VineethReddy02 to emeritus (#2957)
jpkrohling May 15, 2024
c2f569d
Cleanup cluster roles and bindings (#2938)
pavolloffay May 16, 2024
7fafce9
Fixed non-expected warnings on TA webhook. (#2962)
yuriolisa May 16, 2024
53c5046
Verify ServiceMonitor and PodMonitor are installed in prom cr availab…
akselleirv May 17, 2024
f0a2ba9
Bump kyverno/action-install-chainsaw from 0.2.0 to 0.2.1 (#2968)
dependabot[bot] May 20, 2024
b314e7f
Fix labels for Service Monitors (#2878)
iblancasa May 20, 2024
314d7c1
Prepare release 0.100.0 (#2960)
VineethReddy02 May 20, 2024
97495ec
[chore] Refactor allocation strategies (#2928)
swiatekm May 20, 2024
d1126a2
Bring back webhook port (#2973)
jaronoff97 May 20, 2024
435b900
patch 0.100.1 (#2974)
jaronoff97 May 20, 2024
2a9db5f
Update the OpenTelemetry Java agent version to 2.4.0 (#2967)
opentelemetrybot May 21, 2024
eaa4e63
simplify deletion logic (#2971)
jaronoff97 May 21, 2024
ac93c7e
Update maintainers in the operator hub PR (#2977)
pavolloffay May 21, 2024
1a731c9
Support for kubernetes 1.30 version (#2975)
vasireddy99 May 22, 2024
cfc1dc3
[chore] Move TargetAllocator CRD to v1alpha1 (#2918)
swiatekm May 22, 2024
cb7aaa8
[featuregate] Automatically set GOMEMLIMIT and GOMAXPROCS for collect…
jaronoff97 May 22, 2024
5326614
Fix querying OpenShift user workload monitoring stack. (#2984)
IshwarKanse May 23, 2024
a8f63a1
Bump alpine from 3.19 to 3.20 (#2990)
dependabot[bot] May 27, 2024
65d6c4f
Bump alpine from 3.19 to 3.20 in /cmd/operator-opamp-bridge (#2991)
dependabot[bot] May 27, 2024
307a6ba
Bump github.com/go-logr/logr from 1.4.1 to 1.4.2 (#2987)
dependabot[bot] May 27, 2024
8138afe
Bump kyverno/action-install-chainsaw from 0.2.1 to 0.2.2 (#2989)
dependabot[bot] May 27, 2024
cf26609
Bump the otel group with 5 updates (#2986)
dependabot[bot] May 28, 2024
5919733
Bump alpine from 3.19 to 3.20 in /cmd/otel-allocator (#2992)
dependabot[bot] May 28, 2024
fa40888
Keep multiple versions of Collector Config (#2946)
matthagenbuch May 28, 2024
c678e14
Prepare v0.101.0 release (#2994)
TylerHelmuth May 29, 2024
438773a
Add crd metrics usage information (#2825)
rubenvp8510 May 30, 2024
04d107c
Update selector documentation for Target Allocator (#3001)
swiatekm May 31, 2024
5e95eb7
Bump github.com/prometheus/prometheus in the prometheus group (#3004)
dependabot[bot] Jun 3, 2024
365ddf4
Bump kyverno/action-install-chainsaw from 0.2.2 to 0.2.3 (#3003)
dependabot[bot] Jun 3, 2024
bff19dc
Introduce simplified parsers (#2972)
jaronoff97 Jun 3, 2024
0a209c6
Bump go.opentelemetry.io/otel/exporters/prometheus in the otel group …
dependabot[bot] Jun 3, 2024
e14a3e7
Bump go.uber.org/zap from 1.26.0 to 1.27.0 (#3006)
dependabot[bot] Jun 3, 2024
8d5f5af
Update Kafka version in e2e test (#3009)
IshwarKanse Jun 4, 2024
028aa56
[chore] Bump opentelemetry-autoinstrumentation-python to 0.45b0 (#3000)
brandonkzw Jun 4, 2024
10c2575
Fix annotation/label filter setting (#3008)
jaronoff97 Jun 5, 2024
cb266f2
Added Cert Manager CRDs & RBAC validation and management
ItielOlenick Jun 1, 2024
c06c486
Added relevant resources and started adding tests
ItielOlenick Jun 5, 2024
1a39bf1
minor change
ItielOlenick Jun 6, 2024
8affdf2
Minor change
ItielOlenick Jun 6, 2024
446f570
minor change
ItielOlenick Jun 6, 2024
71614fc
Cleanup
ItielOlenick Jun 6, 2024
1078c9d
Cleanup, go tidy and resolved conflics
ItielOlenick Jun 6, 2024
eb0ad3d
Merge branch 'main' into TA-update-configs-to-enable-mtls
ItielOlenick Jun 6, 2024
85c7292
Restored local dev changes
ItielOlenick Jun 6, 2024
815c4d9
Refactored, removed init container, minor changes
ItielOlenick Jun 11, 2024
c7b23d9
Merge remote-tracking branch 'upstream/main' into TA-update-configs-t…
ItielOlenick Jun 11, 2024
2ab7e72
Use correct files in TLS config
ItielOlenick Jun 11, 2024
306f6f3
Added default value to getHttpsListenAddr
ItielOlenick Jun 11, 2024
a1c8dfb
Merge remote-tracking branch 'upstream/main' into TA-update-configs-t…
ItielOlenick Jun 13, 2024
9e1ae16
Added flag to enable mTLS between the Target Allocator and the Collec…
ItielOlenick Jun 13, 2024
caa497e
Using the enable mTLS flag
ItielOlenick Jun 13, 2024
a4aacec
Using feature gate in place of command line flags to enable the feature
ItielOlenick Jun 16, 2024
94363e0
Removed flag from manager yaml
ItielOlenick Jun 16, 2024
2ef561b
Added featuregate func description
ItielOlenick Jun 16, 2024
afdacb6
Initial unit/e2e tests. some cleanup
ItielOlenick Jul 4, 2024
0389c7c
Merged main
ItielOlenick Jul 4, 2024
c3eda01
Using TA params
ItielOlenick Jul 4, 2024
9c12441
Cleanup makefile from local changes
ItielOlenick Jul 4, 2024
bea9947
Added step to create cert manager RBAC for e2e mtls tests
ItielOlenick Jul 4, 2024
e4ff571
Using Kustomize for patching certmanager permissions
ItielOlenick Jul 4, 2024
612546e
Cleanup chainsaw test
ItielOlenick Jul 4, 2024
7dafe91
Cleanup chainsaw tests
ItielOlenick Jul 4, 2024
73d0ce9
e2e test case verifying Collector got secret from TA over mTLS
ItielOlenick Jul 5, 2024
c392952
Added changelog, fixed unit tests
ItielOlenick Jul 5, 2024
475a1e2
restored makefile
ItielOlenick Jul 5, 2024
e293a78
Renamed fg import
ItielOlenick Jul 5, 2024
71ca0c0
Linting rules for imports
ItielOlenick Jul 5, 2024
09bdf3c
Added more tests, updated the readme
ItielOlenick Jul 5, 2024
fd99776
Added steps in e2e tests for new app
ItielOlenick Jul 11, 2024
e239dcc
Merge remote-tracking branch 'upstream/main' into TA-update-configs-t…
ItielOlenick Aug 19, 2024
5410b44
Merge remote-tracking branch 'upstream/main' into TA-update-configs-t…
ItielOlenick Aug 29, 2024
4cd6b9d
Ran go mod tidy
ItielOlenick Aug 29, 2024
ca26b01
Added new variable to test TA's AddTAConfigToPromConfig
ItielOlenick Aug 29, 2024
0460197
Setting otel-col-contrib 0.108.0 in e2e test until operator gets updated
ItielOlenick Aug 30, 2024
e4bc208
Merge branch 'main' into TA-update-configs-to-enable-mtls
ItielOlenick Aug 30, 2024
4093554
Update pkg/featuregate/featuregate.go
ItielOlenick Aug 31, 2024
6f7f817
Added https, serviceMonitor and tls resources assertions to e2e tests
ItielOlenick Aug 31, 2024
80cd205
Using namespaced names for ClusterRoles
ItielOlenick Sep 2, 2024
06b1dfe
Cleanup
ItielOlenick Sep 2, 2024
e073de6
Added CertManager resources unit tests
ItielOlenick Sep 2, 2024
7e412ed
Added unit tests and e2e assertions
ItielOlenick Sep 3, 2024
17ff564
Added missing assertion call
ItielOlenick Sep 3, 2024
7a8e8dd
Update 00-install.yaml
ItielOlenick Sep 10, 2024
e39f354
Merge branch 'main' into TA-update-configs-to-enable-mtls
ItielOlenick Sep 10, 2024
e8f7ae2
Update pkg/featuregate/featuregate.go
ItielOlenick Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .chloggen/TA-update-configs-to-enable-mtls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: target allocator collector
ItielOlenick marked this conversation as resolved.
Show resolved Hide resolved

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Enable mTLS between the TA and collector for passing secrets in the scrape_config securely"

# One or more tracking issues related to the change
issues: [1669]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
This change enables mTLS between the collector and the target allocator.
This is necessary for passing secrets securely from the TA to the collector for scraping endpoints that have authentication.
3 changes: 3 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ jobs:
- e2e-upgrade
- e2e-multi-instrumentation
- e2e-metadata-filters
- e2e-ta-collector-mtls
include:
- group: e2e-instrumentation
setup: "add-instrumentation-params prepare-e2e"
- group: e2e-multi-instrumentation
setup: "add-multi-instrumentation-params prepare-e2e"
- group: e2e-metadata-filters
setup: "add-operator-arg OPERATOR_ARG='--annotations-filter=.*filter.out --annotations-filter=config.*.gke.io.* --labels=.*filter.out' prepare-e2e"
- group: e2e-ta-collector-mtls
setup: "add-operator-arg OPERATOR_ARG='--feature-gates=operator.targetallocator.mtls' add-certmanager-permissions prepare-e2e"
- group: e2e-automatic-rbac
setup: "add-rbac-permissions-to-operator prepare-e2e"
steps:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down Expand Up @@ -39,8 +38,9 @@ config/manager/kustomization.yaml
kubeconfig
tests/_build/
config/rbac/extra-permissions-operator/
config/rbac/certmanager-permissions/

# autoinstrumentation artifacts
build
node_modules
package-lock.json
package-lock.json
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ e2e-prometheuscr: chainsaw
e2e-targetallocator: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-targetallocator

.PHONY: add-certmanager-permissions
add-certmanager-permissions:
# Kustomize only allows patches in the folder where the kustomization is located
# This folder is ignored by .gitignore
cp -r tests/e2e-ta-collector-mtls/certmanager-permissions config/rbac/certmanager-permissions
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path certmanager-permissions/certmanager.yaml

# Target allocator collector mTLS end-to-tests
.PHONY: e2e-ta-collector-mtls
e2e-ta-collector-mtls: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-ta-collector-mtls

# end-to-end-test for Annotations/Labels Filters
.PHONY: e2e-metadata-filters
e2e-metadata-filters: chainsaw
Expand Down
37 changes: 35 additions & 2 deletions cmd/otel-allocator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,42 @@ rules:

### Service / Pod monitor endpoint credentials

If your service or pod monitor endpoints require credentials or other supported form of authentication (bearer token, basic auth, OAuth2 etc.), you need to ensure that the collector has access to this information. Due to some limitations in how the endpoints configuration is handled, target allocator currently does **not** support credentials provided via secrets. It is only possible to provide credentials in a file (for more details see issue https://github.com/open-telemetry/opentelemetry-operator/issues/1669).
If your service or pod monitor endpoints require authentication (such as bearer tokens, basic auth, OAuth2, etc.), you must ensure that the collector has access to these credentials.

To secure the connection between the target allocator and the collector so that the secrets can be retrieved, mTLS is used. This involves the use of cert-manager to manage the CA, server, and client certificates.

Prerequisites:
- Ensure cert-manager is installed in your Kubernetes cluster.
- Grant RBAC Permissions:

- The target allocator needs the appropriate RBAC permissions to get the secrets referenced in the Service / Pod monitor.

- The operator needs the appropriate RBAC permissions to manage cert-manager resources. The following clusterRole can be used to grant the necessary permissions:

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: opentelemetry-operator-controller-manager-cert-manager-role
rules:
- apiGroups:
- cert-manager.io
resources:
- issuers
- certificaterequests
- certificates
verbs:
- create
- get
- list
- watch
- update
- patch
- delete
```

- Enable the `operator.targetallocator.mtls` feature gate in the operator's deployment.

In order to ensure your endpoints can be scraped, your collector instance needs to have the particular secret mounted as a file at the correct path.


# Design
Expand Down
25 changes: 15 additions & 10 deletions cmd/otel-allocator/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,34 @@ func LoadFromCLI(target *Config, flagSet *pflag.FlagSet) error {
target.PrometheusCR.Enabled = prometheusCREnabled
}

target.HTTPS.Enabled, err = getHttpsEnabled(flagSet)
if err != nil {
if httpsEnabled, changed, err := getHttpsEnabled(flagSet); err != nil {
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
return err
} else if changed {
target.HTTPS.Enabled = httpsEnabled
}

target.HTTPS.ListenAddr, err = getHttpsListenAddr(flagSet)
if err != nil {
if listenAddrHttps, changed, err := getHttpsListenAddr(flagSet); err != nil {
return err
} else if changed {
target.HTTPS.ListenAddr = listenAddrHttps
}

target.HTTPS.CAFilePath, err = getHttpsCAFilePath(flagSet)
if err != nil {
if caFilePath, changed, err := getHttpsCAFilePath(flagSet); err != nil {
return err
} else if changed {
target.HTTPS.CAFilePath = caFilePath
}

target.HTTPS.TLSCertFilePath, err = getHttpsTLSCertFilePath(flagSet)
if err != nil {
if tlsCertFilePath, changed, err := getHttpsTLSCertFilePath(flagSet); err != nil {
return err
} else if changed {
target.HTTPS.TLSCertFilePath = tlsCertFilePath
}

target.HTTPS.TLSKeyFilePath, err = getHttpsTLSKeyFilePath(flagSet)
if err != nil {
if tlsKeyFilePath, changed, err := getHttpsTLSKeyFilePath(flagSet); err != nil {
return err
} else if changed {
target.HTTPS.TLSKeyFilePath = tlsKeyFilePath
}

return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/otel-allocator/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestLoad(t *testing.T) {
},
HTTPS: HTTPSServerConfig{
Enabled: true,
ListenAddr: ":8443",
CAFilePath: "/path/to/ca.pem",
TLSCertFilePath: "/path/to/cert.pem",
TLSKeyFilePath: "/path/to/key.pem",
Expand Down
45 changes: 35 additions & 10 deletions cmd/otel-allocator/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,47 @@ func getPrometheusCREnabled(flagSet *pflag.FlagSet) (value bool, changed bool, e
return
}

func getHttpsListenAddr(flagSet *pflag.FlagSet) (string, error) {
return flagSet.GetString(listenAddrHttpsFlagName)
func getHttpsListenAddr(flagSet *pflag.FlagSet) (value string, changed bool, err error) {
if changed = flagSet.Changed(listenAddrHttpsFlagName); !changed {
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
value, err = ":8443", nil
return
}
value, err = flagSet.GetString(listenAddrHttpsFlagName)
return
}

func getHttpsEnabled(flagSet *pflag.FlagSet) (bool, error) {
return flagSet.GetBool(httpsEnabledFlagName)
func getHttpsEnabled(flagSet *pflag.FlagSet) (value bool, changed bool, err error) {
if changed = flagSet.Changed(httpsEnabledFlagName); !changed {
value, err = false, nil
return
}
value, err = flagSet.GetBool(httpsEnabledFlagName)
return
}

func getHttpsCAFilePath(flagSet *pflag.FlagSet) (string, error) {
return flagSet.GetString(httpsCAFilePathFlagName)
func getHttpsCAFilePath(flagSet *pflag.FlagSet) (value string, changed bool, err error) {
if changed = flagSet.Changed(httpsCAFilePathFlagName); !changed {
value, err = "", nil
return
}
value, err = flagSet.GetString(httpsCAFilePathFlagName)
return
}

func getHttpsTLSCertFilePath(flagSet *pflag.FlagSet) (string, error) {
return flagSet.GetString(httpsTLSCertFilePathFlagName)
func getHttpsTLSCertFilePath(flagSet *pflag.FlagSet) (value string, changed bool, err error) {
if changed = flagSet.Changed(httpsTLSCertFilePathFlagName); !changed {
value, err = "", nil
return
}
value, err = flagSet.GetString(httpsTLSCertFilePathFlagName)
return
}

func getHttpsTLSKeyFilePath(flagSet *pflag.FlagSet) (string, error) {
return flagSet.GetString(httpsTLSKeyFilePathFlagName)
func getHttpsTLSKeyFilePath(flagSet *pflag.FlagSet) (value string, changed bool, err error) {
if changed = flagSet.Changed(httpsTLSKeyFilePathFlagName); !changed {
value, err = "", nil
return
}
value, err = flagSet.GetString(httpsTLSKeyFilePathFlagName)
return
}
10 changes: 8 additions & 2 deletions cmd/otel-allocator/config/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ func TestFlagGetters(t *testing.T) {
name: "HttpsServer",
flagArgs: []string{"--" + httpsEnabledFlagName, "true"},
expectedValue: true,
getterFunc: func(fs *pflag.FlagSet) (interface{}, error) { return getHttpsEnabled(fs) },
getterFunc: func(fs *pflag.FlagSet) (interface{}, error) {
value, _, err := getHttpsEnabled(fs)
return value, err
},
},
{
name: "HttpsServerKey",
flagArgs: []string{"--" + httpsTLSKeyFilePathFlagName, "/path/to/tls.key"},
expectedValue: "/path/to/tls.key",
getterFunc: func(fs *pflag.FlagSet) (interface{}, error) { return getHttpsTLSKeyFilePath(fs) },
getterFunc: func(fs *pflag.FlagSet) (interface{}, error) {
value, _, err := getHttpsTLSKeyFilePath(fs)
return value, err
},
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/otel-allocator/config/testdata/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ prometheus_cr:
scrape_interval: 60s
https:
enabled: true
listen_addr: :8443
ca_file_path: /path/to/ca.pem
tls_cert_file_path: /path/to/cert.pem
tls_key_file_path: /path/to/key.pem
Expand Down
Loading
Loading