Skip to content

Commit

Permalink
deprecate kube-rbac-proxy with controller built-in auth protection
Browse files Browse the repository at this point in the history
Signed-off-by: rksharma95 <[email protected]>
  • Loading branch information
rksharma95 committed Dec 19, 2024
1 parent 6bd41e2 commit 4653681
Show file tree
Hide file tree
Showing 58 changed files with 751 additions and 929 deletions.
45 changes: 23 additions & 22 deletions KubeArmor/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/kubearmor/KubeArmor/KubeArmor

go 1.21.0
go 1.22.0

toolchain go1.21.12
toolchain go1.22.9

replace (
github.com/kubearmor/KubeArmor => ../../
Expand Down Expand Up @@ -41,13 +41,13 @@ require (
golang.org/x/sys v0.22.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
k8s.io/cri-api v0.29.7
k8s.io/klog/v2 v2.120.0
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
sigs.k8s.io/controller-runtime v0.15.3
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/controller-runtime v0.19.3
)

require (
Expand All @@ -62,9 +62,10 @@ require (
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
Expand All @@ -82,21 +83,21 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
Expand All @@ -106,15 +107,16 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
Expand All @@ -127,9 +129,8 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
k8s.io/apiextensions-apiserver v0.29.0 // indirect
k8s.io/component-base v0.29.0 // indirect
k8s.io/kube-openapi v0.0.0-20240105020646-a37d4de58910 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
134 changes: 68 additions & 66 deletions KubeArmor/go.sum

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions deployments/get/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ var (
KubeArmorControllerClusterRoleBindingName = "kubearmor-controller-clusterrolebinding"
KubeArmorControllerLeaderElectionRoleName = "kubearmor-controller-leader-election-role"
KubeArmorControllerLeaderElectionRoleBindingName = "kubearmor-controller-leader-election-rolebinding"
KubeArmorControllerProxyRoleName = "kubearmor-controller-proxy-role"
KubeArmorControllerProxyRoleBindingName = "kubearmor-controller-proxy-rolebinding"
KubeArmorControllerMetricsReaderRoleName = "kubearmor-controller-metrics-reader-role"
KubeArmorControllerMetricsReaderRoleBindingName = "kubearmor-controller-metrics-reader-rolebinding"
KubeArmorControllerMetricsServiceName = "kubearmor-controller-metrics-service"
KubeArmorControllerWebhookServiceName = "kubearmor-controller-webhook-service"
KubeArmorControllerSecretName = "kubearmor-controller-webhook-server-cert"
KubeArmorControllerMutatingWebhookConfiguration = "kubearmor-controller-mutating-webhook-configuration"
Expand Down
150 changes: 1 addition & 149 deletions deployments/get/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,32 +475,6 @@ var KubeArmorControllerLabels = map[string]string{
"kubearmor-app": "kubearmor-controller",
}

// GetKubeArmorControllerService Function
func GetKubeArmorControllerMetricsService(namespace string) *corev1.Service {
return &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: KubeArmorControllerMetricsServiceName,
Labels: KubeArmorControllerLabels,
Namespace: namespace,
},
Spec: corev1.ServiceSpec{
Selector: KubeArmorControllerLabels,
Ports: []corev1.ServicePort{
{
Name: "https",
Protocol: corev1.ProtocolTCP,
Port: int32(8443),
TargetPort: intstr.FromString("https"),
},
},
},
}
}

var KubeArmorControllerCertVolumeDefaultMode = int32(420)

var KubeArmorControllerCertVolume = corev1.Volume{
Expand Down Expand Up @@ -536,8 +510,7 @@ func GetKubeArmorControllerDeployment(namespace string) *appsv1.Deployment {
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"kubearmor-policy": "audited",
"container.apparmor.security.beta.kubernetes.io/manager": "unconfined",
"container.apparmor.security.beta.kubernetes.io/kube-rbac-proxy": "unconfined",
"container.apparmor.security.beta.kubernetes.io/manager": "unconfined",
},
Labels: KubeArmorControllerLabels,
},
Expand All @@ -547,37 +520,10 @@ func GetKubeArmorControllerDeployment(namespace string) *appsv1.Deployment {
KubeArmorControllerCertVolume,
},
Containers: []corev1.Container{
{
Name: "kube-rbac-proxy",
Image: "gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0",
Args: []string{
"--secure-listen-address=0.0.0.0:8443",
"--upstream=http://127.0.0.1:8080/",
"--logtostderr=true",
"--v=10",
},
Ports: []corev1.ContainerPort{
{
ContainerPort: 8443,
Name: "https",
},
},
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("40Mi"),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("20Mi"),
},
},
},
{
Name: "manager",
Image: "kubearmor/kubearmor-controller:latest",
Args: []string{
"--metrics-bind-address=127.0.0.1:8080",
"--leader-elect",
"--health-probe-bind-address=:8081",
},
Expand Down Expand Up @@ -765,100 +711,6 @@ func GetKubeArmorControllerLeaderElectionRoleBinding(namespace string) *rbacv1.R
}
}

// GetKubeArmorControllerProxyRole Function
func GetKubeArmorControllerProxyRole() *rbacv1.ClusterRole {
return &rbacv1.ClusterRole{
TypeMeta: metav1.TypeMeta{
Kind: "ClusterRole",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: KubeArmorControllerProxyRoleName,
},
Rules: []rbacv1.PolicyRule{
{
APIGroups: []string{"authentication.k8s.io"},
Resources: []string{"tokenreviews"},
Verbs: []string{"create"},
},
{
APIGroups: []string{"authorization.k8s.io"},
Resources: []string{"subjectaccessreviews"},
Verbs: []string{"create"},
},
},
}
}

// GetKubeArmorControllerProxyRoleBinding Function
func GetKubeArmorControllerProxyRoleBinding(namespace string) *rbacv1.ClusterRoleBinding {
return &rbacv1.ClusterRoleBinding{
TypeMeta: metav1.TypeMeta{
Kind: "ClusterRoleBinding",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: KubeArmorControllerProxyRoleBindingName,
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
Name: KubeArmorControllerProxyRoleName,
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Name: KubeArmorControllerServiceAccountName,
Namespace: namespace,
},
},
}
}

// GetKubeArmorControllerMetricsReaderRole Function
func GetKubeArmorControllerMetricsReaderRole() *rbacv1.ClusterRole {
return &rbacv1.ClusterRole{
TypeMeta: metav1.TypeMeta{
Kind: "ClusterRole",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: KubeArmorControllerMetricsReaderRoleName,
},
Rules: []rbacv1.PolicyRule{
{
NonResourceURLs: []string{"/metrics"},
Verbs: []string{"get"},
},
},
}
}

// GetKubeArmorControllerMetricsReaderRoleBinding Function
func GetKubeArmorControllerMetricsReaderRoleBinding(namespace string) *rbacv1.ClusterRoleBinding {
return &rbacv1.ClusterRoleBinding{
TypeMeta: metav1.TypeMeta{
Kind: "ClusterRoleBinding",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: KubeArmorControllerMetricsReaderRoleBindingName,
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
Name: KubeArmorControllerMetricsReaderRoleName,
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Name: KubeArmorControllerServiceAccountName,
Namespace: namespace,
},
},
}
}

// GetKubeArmorControllerWebhookService Function
func GetKubeArmorControllerWebhookService(namespace string) *corev1.Service {
return &corev1.Service{
Expand Down
18 changes: 10 additions & 8 deletions deployments/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/kubearmor/KubeArmor/deployments

go 1.21.0
go 1.22.0

toolchain go1.21.12
toolchain go1.23.3

replace (
github.com/kubearmor/KubeArmor => ../
Expand All @@ -14,14 +14,15 @@ require (
github.com/clarketm/json v1.17.1
github.com/kubearmor/KubeArmor/KubeArmor v0.0.0-20240110164432-c2c1b121cd94
github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20240110164432-c2c1b121cd94
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -39,6 +40,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e // indirect
Expand All @@ -49,9 +51,9 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.0 // indirect
k8s.io/klog/v2 v2.120.0 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Loading

0 comments on commit 4653681

Please sign in to comment.