Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Changed API namespace and CRD (#67)
Browse files Browse the repository at this point in the history
o11y.splunk.com:SplunkOtelAgent > otel.splunk.com:Agent
  • Loading branch information
owais authored Dec 21, 2021
1 parent cfecce4 commit 2f202ff
Show file tree
Hide file tree
Showing 70 changed files with 412 additions and 468 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ensure-generate-is-noop: set-image-controller generate bundle
@# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check
@git restore config/manager/kustomization.yaml
# TODO(splunk): Check if resources are in sync another way, this only checks if the resources are in sync from the last commit.
@git diff --exit-code apis/o11y/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@git diff --exit-code apis/otel/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@git diff --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && exit 1)


Expand Down
6 changes: 3 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ resources:
namespaced: true
controller: true
domain: splunk.com
group: o11y
kind: SplunkOtelAgent
path: github.com/signalfx/splunk-otel-collector-operator/apis/o11y/v1alpha1
group: otel
kind: Agent
path: github.com/signalfx/splunk-otel-collector-operator/apis/otel/v1alpha1
version: v1alpha1
webhooks:
defaulting: true
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Once the `splunk-otel--operator` deployment is ready, create an Splunk OpenTelem

```console
$ kubectl apply -f - <<EOF
apiVersion: o11y.splunk.com/v1alpha1
kind: SplunkOtelAgent
apiVersion: otel.splunk.com/v1alpha1
kind: Agent
metadata:
name: splunk-otel
namespace: splunk-otel-operator-system
Expand Down Expand Up @@ -72,7 +72,7 @@ spec:
image: my-java-app:latest
```
Then you can automatically instrument it by add `o11y.splunk.com/inject-java: "true"` to the Pod spec (not the deployment) so that it would look like the following:
Then you can automatically instrument it by add `otel.splunk.com/inject-java: "true"` to the Pod spec (not the deployment) so that it would look like the following:

```yaml
apiVersion: apps/v1
Expand All @@ -83,7 +83,7 @@ spec:
template:
metadata:
annotations:
o11y.splunk.com/inject-java: "true"
otel.splunk.com/inject-java: "true"
spec:
containers:
- name: my-java-app
Expand All @@ -94,11 +94,11 @@ This will automatically inject [Splunk OpenTelemetry Java Agent](github.com/sign

Right now the following annotations are supported:

### o11y.splunk.com/inject-java
### otel.splunk.com/inject-java

When this instrumentation is set to `"true"` on a pod, the operator automatically instruments the pod with the Splunk OpenTelemetry Java agent and configures it to send all telemetry data to the OpenTelemetry agents managed by the operator.

### o11y.splunk.com/inject-config
### otel.splunk.com/inject-config

When this instrumentation is set to `"true"` on a pod, the operator only configures the pod to send all telemetry data to the OpenTelemetry agents managed by the operator. Pods are not instrumented in this case and that is left to the user.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package v1 contains API Schema definitions for the o11y v1 API group
// Package v1 contains API Schema definitions for the otel v1 API group
//+kubebuilder:object:generate=true
//+groupName=o11y.splunk.com
//+groupName=otel.splunk.com
package v1alpha1

import (
Expand All @@ -24,7 +24,7 @@ import (

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "o11y.splunk.com", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "otel.splunk.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type SplunkCollectorSpec struct {
type CollectorSpec struct {
// Disabled determines whether this spec will be depoyed or not.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Expand Down Expand Up @@ -127,8 +127,8 @@ type AutoInstrumentation struct {
Image string `json:"image,omitempty"`
}

// SplunkOtelAgentSpec defines the desired state of SplunkOtelAgent.
type SplunkOtelAgentSpec struct {
// AgentSpec defines the desired state of SplunkOtelAgent.
type AgentSpec struct {
// ClusterName is the name of the Kubernetes cluster. This will be used to identify this cluster in Splunk dashboards.
// +required
// +kubebuilder:validation:Required
Expand All @@ -149,21 +149,21 @@ type SplunkOtelAgentSpec struct {
// Agent is a Splunk OpenTelemetry Collector instance deployed as an agent on every node.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Agent SplunkCollectorSpec `json:"agent,omitempty"`
Agent CollectorSpec `json:"agent,omitempty"`

// ClusterReceiver is a single instance Splunk OpenTelemetry Collector deployement used to monitor the entire cluster.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
ClusterReceiver SplunkCollectorSpec `json:"clusterReceiver,omitempty"`
ClusterReceiver CollectorSpec `json:"clusterReceiver,omitempty"`

// ClusterReceiver is a Splunk OpenTelemetry Collector deployement used to export data to Splunk APM.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Gateway SplunkCollectorSpec `json:"gateway,omitempty"`
Gateway CollectorSpec `json:"gateway,omitempty"`
}

// SplunkOtelAgentStatus defines the observed state of SplunkOtelAgent.
type SplunkOtelAgentStatus struct {
// AgentStatus defines the observed state of SplunkOtelAgent.
type AgentStatus struct {
// Version of the managed OpenTelemetry Collector (operand).
Version string `json:"version,omitempty"`

Expand All @@ -178,24 +178,24 @@ type SplunkOtelAgentStatus struct {
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="Splunk OpenTelemetry Operator Version"
// +operator-sdk:csv:customresourcedefinitions:displayName="Splunk OpenTelemetry Collector"

// SplunkOtelAgent is the Schema for the splunkotelagents API.
type SplunkOtelAgent struct {
// Agent is the Schema for the agents API.
type Agent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SplunkOtelAgentSpec `json:"spec,omitempty"`
Status SplunkOtelAgentStatus `json:"status,omitempty"`
Spec AgentSpec `json:"spec,omitempty"`
Status AgentStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// SplunkOtelAgentList contains a list of SplunkOtelAgent.
type SplunkOtelAgentList struct {
// AgentList contains a list of SplunkOtelAgent.
type AgentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SplunkOtelAgent `json:"items"`
Items []Agent `json:"items"`
}

func init() {
SchemeBuilder.Register(&SplunkOtelAgent{}, &SplunkOtelAgentList{})
SchemeBuilder.Register(&Agent{}, &AgentList{})
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const (
)

// log is for logging in this package.
var splunkotelagentlog = logf.Log.WithName("splunkotelagent-resource")
var agentlog = logf.Log.WithName("agent-resource")

var detectedDistro autodetect.Distro = autodetect.UnknownDistro

func (r *SplunkOtelAgent) SetupWebhookWithManager(mgr ctrl.Manager, distro autodetect.Distro) error {
func (r *Agent) SetupWebhookWithManager(mgr ctrl.Manager, distro autodetect.Distro) error {
detectedDistro = distro
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand All @@ -45,13 +45,13 @@ func (r *SplunkOtelAgent) SetupWebhookWithManager(mgr ctrl.Manager, distro autod

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-o11y-splunk-com-v1alpha1-splunkotelagent,mutating=true,failurePolicy=fail,sideEffects=None,groups=o11y.splunk.com,resources=splunkotelagents,verbs=create;update,versions=v1alpha1,name=msplunkotelagent.kb.io,admissionReviewVersions={v1,v1beta1}
//+kubebuilder:webhook:path=/mutate-otel-splunk-com-v1alpha1-agent,mutating=true,failurePolicy=fail,sideEffects=None,groups=otel.splunk.com,resources=agents,verbs=create;update,versions=v1alpha1,name=magent.kb.io,admissionReviewVersions={v1,v1beta1}

var _ webhook.Defaulter = &SplunkOtelAgent{}
var _ webhook.Defaulter = &Agent{}

// Default implements webhook.Defaulter so a webhook will be registered for the type.
func (r *SplunkOtelAgent) Default() {
splunkotelagentlog.Info("default", "name", r.Name)
func (r *Agent) Default() {
agentlog.Info("default", "name", r.Name)

if r.Labels == nil {
r.Labels = map[string]string{}
Expand All @@ -67,29 +67,29 @@ func (r *SplunkOtelAgent) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-o11y-splunk-com-v1alpha1-splunkotelagent,mutating=false,failurePolicy=fail,sideEffects=None,groups=o11y.splunk.com,resources=splunkotelagents,verbs=create;update,versions=v1alpha1,name=vsplunkotelagent.kb.io,admissionReviewVersions={v1,v1beta1}
//+kubebuilder:webhook:path=/validate-otel-splunk-com-v1alpha1-agent,mutating=false,failurePolicy=fail,sideEffects=None,groups=otel.splunk.com,resources=agents,verbs=create;update,versions=v1alpha1,name=vagent.kb.io,admissionReviewVersions={v1,v1beta1}

var _ webhook.Validator = &SplunkOtelAgent{}
var _ webhook.Validator = &Agent{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (r *SplunkOtelAgent) ValidateCreate() error {
splunkotelagentlog.Info("validate create", "name", r.Name)
func (r *Agent) ValidateCreate() error {
agentlog.Info("validate create", "name", r.Name)
return r.validateCRDSpec()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (r *SplunkOtelAgent) ValidateUpdate(old runtime.Object) error {
splunkotelagentlog.Info("validate update", "name", r.Name)
func (r *Agent) ValidateUpdate(old runtime.Object) error {
agentlog.Info("validate update", "name", r.Name)
return r.validateCRDSpec()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (r *SplunkOtelAgent) ValidateDelete() error {
splunkotelagentlog.Info("validate delete", "name", r.Name)
func (r *Agent) ValidateDelete() error {
agentlog.Info("validate delete", "name", r.Name)
return nil
}

func (r *SplunkOtelAgent) validateCRDSpec() error {
func (r *Agent) validateCRDSpec() error {
var errs []string

if err := r.validateInstrumentation(); err != nil {
Expand All @@ -113,11 +113,11 @@ func (r *SplunkOtelAgent) validateCRDSpec() error {
return nil
}

func (r *SplunkOtelAgent) validateInstrumentation() error {
func (r *Agent) validateInstrumentation() error {
return nil
}

func (r *SplunkOtelAgent) validateCRDAgentSpec() error {
func (r *Agent) validateCRDAgentSpec() error {
spec := r.Spec.Agent

if spec.Replicas != nil {
Expand All @@ -127,7 +127,7 @@ func (r *SplunkOtelAgent) validateCRDAgentSpec() error {
return nil
}

func (r *SplunkOtelAgent) validateCRDClusterReceiverSpec() error {
func (r *Agent) validateCRDClusterReceiverSpec() error {
spec := r.Spec.ClusterReceiver

if spec.Replicas != nil {
Expand All @@ -141,7 +141,7 @@ func (r *SplunkOtelAgent) validateCRDClusterReceiverSpec() error {
return nil
}

func (r *SplunkOtelAgent) validateCRDGatewaySpec() error {
func (r *Agent) validateCRDGatewaySpec() error {
spec := r.Spec.Gateway

if !r.Spec.Gateway.Disabled {
Expand All @@ -155,13 +155,13 @@ func (r *SplunkOtelAgent) validateCRDGatewaySpec() error {
return nil
}

func (r *SplunkOtelAgent) defaultInstrumentation() {
func (r *Agent) defaultInstrumentation() {
if r.Spec.Instrumentation.Java.Image == "" {
r.Spec.Instrumentation.Java.Image = defaultJavaAgentImage
}
}

func (r *SplunkOtelAgent) defaultAgent() {
func (r *Agent) defaultAgent() {
realm := r.Spec.Realm
clusterName := r.Spec.ClusterName

Expand Down Expand Up @@ -251,7 +251,7 @@ func (r *SplunkOtelAgent) defaultAgent() {
}
}

func (r *SplunkOtelAgent) defaultClusterReceiver() {
func (r *Agent) defaultClusterReceiver() {
realm := r.Spec.Realm
clusterName := r.Spec.ClusterName

Expand Down Expand Up @@ -296,7 +296,7 @@ func (r *SplunkOtelAgent) defaultClusterReceiver() {
}
}

func (r *SplunkOtelAgent) defaultGateway() {
func (r *Agent) defaultGateway() {
spec := &r.Spec.Gateway
// TODO(splunk): forcibly disable gateway until we add support for it.
spec.Disabled = true
Expand Down
Loading

0 comments on commit 2f202ff

Please sign in to comment.