Skip to content

Commit 4b3bf93

Browse files
committed
wip
1 parent 7e42515 commit 4b3bf93

12 files changed

Lines changed: 173 additions & 20 deletions

File tree

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,26 @@ deploy: install-gateway-api-crds set-image-controller
333333
undeploy: set-image-controller
334334
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
335335

336+
##@ Standalone OpAMP Bridge (no operator / CRDs required)
337+
338+
# Deploy the standalone OpAMP bridge into the current Kubernetes context.
339+
# Does not require the operator, CRDs, or cert-manager.
340+
.PHONY: deploy-standalone-bridge
341+
deploy-standalone-bridge: kustomize
342+
cd config/standalone-bridge && $(KUSTOMIZE) edit set image operator-opamp-bridge=${OPERATOROPAMPBRIDGE_IMG}
343+
$(KUSTOMIZE) build config/standalone-bridge | kubectl apply -f -
344+
kubectl rollout status deployment/otel-opamp-bridge-standalone -n opentelemetry-opamp-bridge --timeout=120s
345+
346+
# Undeploy the standalone OpAMP bridge from the current Kubernetes context.
347+
.PHONY: undeploy-standalone-bridge
348+
undeploy-standalone-bridge: kustomize
349+
$(KUSTOMIZE) build config/standalone-bridge | kubectl delete --ignore-not-found=true -f -
350+
351+
# Build, load, and deploy the standalone bridge to a kind cluster.
352+
# Assumes a kind cluster is already running (use start-kind first).
353+
.PHONY: deploy-standalone-bridge-kind
354+
deploy-standalone-bridge-kind: load-image-operator-opamp-bridge deploy-standalone-bridge
355+
336356
# Generates the released manifests
337357
.PHONY: release-artifacts
338358
release-artifacts: set-image-controller

cmd/operator-opamp-bridge/internal/config/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const (
7575
)
7676

7777
// TargetWorkload describes a Deployment or DaemonSet whose collector config
78-
// is managed via a ConfigMap. Used only in "plain" mode.
78+
// is managed via a ConfigMap. Used only in "standalone" mode.
7979
type TargetWorkload struct {
8080
Name string `yaml:"name"`
8181
Namespace string `yaml:"namespace"`
@@ -104,10 +104,10 @@ type Config struct {
104104
AgentDescription AgentDescription `yaml:"description,omitempty"`
105105

106106
// Mode selects the operating mode: "operator" (default) uses OpenTelemetryCollector CRDs,
107-
// "plain" manages ConfigMaps for standard Deployments/DaemonSets.
107+
// "standalone" manages ConfigMaps for standard Deployments/DaemonSets.
108108
Mode string `yaml:"mode,omitempty"`
109109

110-
// Targets defines the workloads to manage in "plain" mode.
110+
// Targets defines the workloads to manage in "standalone" mode.
111111
Targets []TargetWorkload `yaml:"targets,omitempty"`
112112
}
113113

@@ -243,7 +243,7 @@ func (c *Config) RemoteConfigEnabled() bool {
243243
}
244244

245245
func (c *Config) GetKubernetesClient() (client.Client, error) {
246-
if c.Mode != "plain" {
246+
if c.Mode != "standalone" {
247247
err := schemeBuilder.AddToScheme(scheme.Scheme)
248248
if err != nil {
249249
return nil, err
@@ -254,8 +254,8 @@ func (c *Config) GetKubernetesClient() (client.Client, error) {
254254
})
255255
}
256256

257-
func (c *Config) IsPlainMode() bool {
258-
return c.Mode == "plain"
257+
func (c *Config) IsStandaloneMode() bool {
258+
return c.Mode == "standalone"
259259
}
260260

261261
func (c *Config) GetTargets() []TargetWorkload {

cmd/operator-opamp-bridge/internal/config/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func GetFlagSet(errorHandling pflag.ErrorHandling) *pflag.FlagSet {
4040
flagSet.String(kubeConfigPathFlagName, defaultKubeConfigPath, "absolute path to the KubeconfigPath file.")
4141
flagSet.Duration(heartbeatIntervalFlagName, defaultHeartbeatInterval, "The interval to use for sending a heartbeat. Setting it to 0 disables the heartbeat.")
4242
flagSet.String(nameFlagName, opampBridgeName, "The name of the bridge to use for querying managed collectors.")
43-
flagSet.String(modeFlagName, "", `Operating mode: "operator" (default, uses CRDs) or "plain" (manages ConfigMaps for Deployments/DaemonSets).`)
43+
flagSet.String(modeFlagName, "", `Operating mode: "operator" (default, uses CRDs) or "standalone" (manages ConfigMaps for Deployments/DaemonSets).`)
4444
zapFlagSet := flag.NewFlagSet("", flag.ErrorHandling(errorHandling))
4545
zapCmdLineOpts.BindFlags(zapFlagSet)
4646
flagSet.AddGoFlagSet(zapFlagSet)

cmd/operator-opamp-bridge/internal/workload/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type TargetWorkload struct {
3838
ConfigMapKey string `yaml:"configMapKey"`
3939
}
4040

41-
// Client implements operator.ConfigApplier for plain Deployment/DaemonSet
41+
// Client implements operator.ConfigApplier for standalone Deployment/DaemonSet
4242
// workloads. Configuration is managed through ConfigMaps rather than CRDs.
4343
type Client struct {
4444
log logr.Logger
@@ -157,7 +157,7 @@ func (c *Client) GetCollectorPods(selectorLabels map[string]string, namespace st
157157
return podList, err
158158
}
159159

160-
func (c *Client) getInstance(ctx context.Context, target TargetWorkload) (*plainCollectorInstance, error) {
160+
func (c *Client) getInstance(ctx context.Context, target TargetWorkload) (*standaloneCollectorInstance, error) {
161161
var selectorLabels map[string]string
162162
var creationTimestamp time.Time
163163
var statusReplicas string
@@ -204,7 +204,7 @@ func (c *Client) getInstance(ctx context.Context, target TargetWorkload) (*plain
204204
configBody = []byte(cm.Data[target.ConfigMapKey])
205205
}
206206

207-
return &plainCollectorInstance{
207+
return &standaloneCollectorInstance{
208208
name: target.Name,
209209
namespace: target.Namespace,
210210
createdAt: creationTimestamp,

cmd/operator-opamp-bridge/internal/workload/plain_instance.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"github.com/open-telemetry/opentelemetry-operator/cmd/operator-opamp-bridge/internal/operator"
1010
)
1111

12-
var _ operator.CollectorInstance = &plainCollectorInstance{}
12+
var _ operator.CollectorInstance = &standaloneCollectorInstance{}
1313

14-
type plainCollectorInstance struct {
14+
type standaloneCollectorInstance struct {
1515
name string
1616
namespace string
1717
createdAt time.Time
@@ -20,26 +20,26 @@ type plainCollectorInstance struct {
2020
configBody []byte
2121
}
2222

23-
func (p *plainCollectorInstance) GetName() string {
23+
func (p *standaloneCollectorInstance) GetName() string {
2424
return p.name
2525
}
2626

27-
func (p *plainCollectorInstance) GetNamespace() string {
27+
func (p *standaloneCollectorInstance) GetNamespace() string {
2828
return p.namespace
2929
}
3030

31-
func (p *plainCollectorInstance) GetCreationTimestamp() time.Time {
31+
func (p *standaloneCollectorInstance) GetCreationTimestamp() time.Time {
3232
return p.createdAt
3333
}
3434

35-
func (p *plainCollectorInstance) GetSelectorLabels() map[string]string {
35+
func (p *standaloneCollectorInstance) GetSelectorLabels() map[string]string {
3636
return p.selectorLabels
3737
}
3838

39-
func (p *plainCollectorInstance) GetStatusReplicas() string {
39+
func (p *standaloneCollectorInstance) GetStatusReplicas() string {
4040
return p.statusReplicas
4141
}
4242

43-
func (p *plainCollectorInstance) GetEffectiveConfig() []byte {
43+
func (p *standaloneCollectorInstance) GetEffectiveConfig() []byte {
4444
return p.configBody
4545
}

cmd/operator-opamp-bridge/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ func main() {
3232
}
3333

3434
var applier operator.ConfigApplier
35-
if cfg.IsPlainMode() {
35+
if cfg.IsStandaloneMode() {
3636
targets := cfg.GetTargets()
3737
if len(targets) == 0 {
38-
l.Error(nil, "plain mode requires at least one target workload")
38+
l.Error(nil, "standalone mode requires at least one target workload")
3939
os.Exit(1)
4040
}
4141
wlTargets := make([]workload.TargetWorkload, len(targets))
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: otel-opamp-bridge-standalone-config
5+
namespace: opentelemetry-opamp-bridge
6+
data:
7+
config.yaml: |
8+
mode: standalone
9+
endpoint: ws://opamp-server:4320/v1/opamp
10+
listenAddr: ":8080"
11+
heartbeatInterval: 30s
12+
name: opamp-bridge-standalone
13+
capabilities:
14+
AcceptsRemoteConfig: true
15+
ReportsEffectiveConfig: true
16+
ReportsHealth: true
17+
ReportsOwnMetrics: true
18+
targets: []
19+
# Example target:
20+
targets:
21+
- name: my-collector
22+
namespace: default
23+
kind: Deployment
24+
workloadName: otelcol
25+
configMapName: otelcol-config
26+
configMapKey: collector.yaml
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: otel-opamp-bridge-standalone
5+
namespace: opentelemetry-opamp-bridge
6+
labels:
7+
app.kubernetes.io/name: otel-opamp-bridge-standalone
8+
app.kubernetes.io/component: opamp-bridge
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app.kubernetes.io/name: otel-opamp-bridge-standalone
14+
template:
15+
metadata:
16+
labels:
17+
app.kubernetes.io/name: otel-opamp-bridge-standalone
18+
app.kubernetes.io/component: opamp-bridge
19+
spec:
20+
serviceAccountName: otel-opamp-bridge-standalone
21+
containers:
22+
- name: bridge
23+
image: operator-opamp-bridge:latest
24+
args:
25+
- --config-file=/conf/config.yaml
26+
- --mode=standalone
27+
ports:
28+
- name: opamp
29+
containerPort: 8080
30+
protocol: TCP
31+
volumeMounts:
32+
- name: config
33+
mountPath: /conf
34+
readOnly: true
35+
livenessProbe:
36+
httpGet:
37+
path: /v1/opamp
38+
port: opamp
39+
initialDelaySeconds: 5
40+
periodSeconds: 10
41+
resources:
42+
requests:
43+
cpu: 50m
44+
memory: 64Mi
45+
limits:
46+
cpu: 200m
47+
memory: 128Mi
48+
volumes:
49+
- name: config
50+
configMap:
51+
name: otel-opamp-bridge-standalone-config
52+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
namespace: opentelemetry-opamp-bridge
5+
6+
resources:
7+
- namespace.yaml
8+
- serviceaccount.yaml
9+
- rbac.yaml
10+
- configmap.yaml
11+
- deployment.yaml
12+
13+
images:
14+
- name: operator-opamp-bridge
15+
newName: ghcr.io/open-telemetry/opentelemetry-operator/operator-opamp-bridge
16+
newTag: v0.148.0-50-g7e425156
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: opentelemetry-opamp-bridge

0 commit comments

Comments
 (0)