-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Odiglet based architecture - first phase (#44)
This PR is the first phase of using odiglet (inspired by kubelet from Kubernetes) daemonset for making instrumentations. More documentation and explanation will be added soon.
- Loading branch information
Showing
166 changed files
with
24,000 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"github.com/keyval-dev/odigos/cli/pkg/labels" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
rbacv1 "k8s.io/api/rbac/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
odigletImage = "ghcr.io/keyval-dev/odigos/odiglet" | ||
) | ||
|
||
func NewOdigletServiceAccount() *corev1.ServiceAccount { | ||
return &corev1.ServiceAccount{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "ServiceAccount", | ||
APIVersion: "v1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "odiglet", | ||
Labels: labels.OdigosSystem, | ||
}, | ||
} | ||
} | ||
|
||
func NewOdigletClusterRole() *rbacv1.ClusterRole { | ||
return &rbacv1.ClusterRole{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "ClusterRole", | ||
APIVersion: "rbac.authorization.k8s.io/v1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "odiglet", | ||
Labels: labels.OdigosSystem, | ||
}, | ||
Rules: []rbacv1.PolicyRule{ | ||
{ | ||
Verbs: []string{ | ||
"create", | ||
"delete", | ||
"get", | ||
"list", | ||
"patch", | ||
"update", | ||
"watch", | ||
}, | ||
APIGroups: []string{""}, | ||
Resources: []string{ | ||
"pods", | ||
}, | ||
}, | ||
{ | ||
Verbs: []string{ | ||
"get", | ||
"update", | ||
"patch", | ||
}, | ||
APIGroups: []string{""}, | ||
Resources: []string{ | ||
"pods/status", | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func NewOdigletClusterRoleBinding(ns string) *rbacv1.ClusterRoleBinding { | ||
return &rbacv1.ClusterRoleBinding{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "ClusterRoleBinding", | ||
APIVersion: "rbac.authorization.k8s.io/v1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "odiglet", | ||
Labels: labels.OdigosSystem, | ||
}, | ||
Subjects: []rbacv1.Subject{ | ||
{ | ||
Kind: "ServiceAccount", | ||
Name: "odiglet", | ||
Namespace: ns, | ||
}, | ||
}, | ||
RoleRef: rbacv1.RoleRef{ | ||
APIGroup: "rbac.authorization.k8s.io", | ||
Kind: "ClusterRole", | ||
Name: "odiglet", | ||
}, | ||
} | ||
} | ||
|
||
func NewOdigletDaemonSet(version string) *appsv1.DaemonSet { | ||
return &appsv1.DaemonSet{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "DaemonSet", | ||
APIVersion: "apps/v1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "odiglet", | ||
Labels: map[string]string{ | ||
"app": "odiglet", | ||
labels.OdigosSystemLabelKey: labels.OdigosSystemLabelValue, | ||
}, | ||
}, | ||
Spec: appsv1.DaemonSetSpec{ | ||
Selector: &metav1.LabelSelector{ | ||
MatchLabels: map[string]string{ | ||
"app": "odiglet", | ||
}, | ||
}, | ||
Template: corev1.PodTemplateSpec{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: map[string]string{ | ||
"app": "odiglet", | ||
}, | ||
}, | ||
Spec: corev1.PodSpec{ | ||
Volumes: []corev1.Volume{ | ||
{ | ||
Name: "run-dir", | ||
VolumeSource: corev1.VolumeSource{ | ||
HostPath: &corev1.HostPathVolumeSource{ | ||
Path: "/run", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "var-dir", | ||
VolumeSource: corev1.VolumeSource{ | ||
HostPath: &corev1.HostPathVolumeSource{ | ||
Path: "/var", | ||
}, | ||
}, | ||
}, | ||
}, | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: "odiglet", | ||
Image: fmt.Sprintf("%s:%s", odigletImage, version), | ||
Env: []corev1.EnvVar{ | ||
{ | ||
Name: "NODE_NAME", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
FieldRef: &corev1.ObjectFieldSelector{ | ||
FieldPath: "spec.nodeName", | ||
}, | ||
}, | ||
}, | ||
}, | ||
Resources: corev1.ResourceRequirements{}, | ||
VolumeMounts: []corev1.VolumeMount{ | ||
{ | ||
Name: "run-dir", | ||
MountPath: "/run", | ||
MountPropagation: ptrMountPropagationMode("Bidirectional"), | ||
}, | ||
{ | ||
Name: "var-dir", | ||
MountPath: "/var", | ||
MountPropagation: ptrMountPropagationMode("Bidirectional"), | ||
}, | ||
}, | ||
ImagePullPolicy: "IfNotPresent", | ||
SecurityContext: &corev1.SecurityContext{ | ||
Privileged: ptrbool(true), | ||
}, | ||
}, | ||
}, | ||
DNSPolicy: "ClusterFirstWithHostNet", | ||
ServiceAccountName: "odiglet", | ||
HostNetwork: true, | ||
HostPID: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
func ptrMountPropagationMode(p corev1.MountPropagationMode) *corev1.MountPropagationMode { | ||
return &p | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM golang:1.19 AS build | ||
WORKDIR /app | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o init | ||
|
||
FROM busybox | ||
WORKDIR /odigos | ||
COPY --from=build /app/init /odigos-init/init | ||
RUN chmod -R go+r /odigos-init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/keyval-dev/odigos/init | ||
|
||
go 1.19 |
Oops, something went wrong.