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

Trust OpenShift service CA in kserve-router #426

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ var (
MultiNodeHead = "head"
)

// OpenShift constants
const (
OpenShiftServiceCaConfigMapName = "openshift-service-ca.crt"
)

// GetRawServiceLabel generate native service label
func GetRawServiceLabel(service string) string {
return "isvc." + service
Expand Down
66 changes: 66 additions & 0 deletions pkg/controller/v1alpha1/inferencegraph/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ var _ = Describe("Inference Graph controller test", func() {
{
Image: "kserve/router:v0.10.0",
Env: []v1.EnvVar{
{
Name: "SSL_CERT_FILE",
Value: "/etc/odh/openshift-service-ca-bundle/service-ca.crt",
},
{
Name: "PROPAGATE_HEADERS",
Value: "Authorization,Intuit_tid",
Expand Down Expand Up @@ -175,9 +179,27 @@ var _ = Describe("Inference Graph controller test", func() {
Drop: []v1.Capability{v1.Capability("ALL")},
},
},
VolumeMounts: []v1.VolumeMount{
{
Name: "openshift-service-ca-bundle",
MountPath: "/etc/odh/openshift-service-ca-bundle",
},
},
},
},
AutomountServiceAccountToken: proto.Bool(false),
Volumes: []v1.Volume{
{
Name: "openshift-service-ca-bundle",
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{
Name: constants.OpenShiftServiceCaConfigMapName,
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -283,6 +305,10 @@ var _ = Describe("Inference Graph controller test", func() {
{
Image: "kserve/router:v0.10.0",
Env: []v1.EnvVar{
{
Name: "SSL_CERT_FILE",
Value: "/etc/odh/openshift-service-ca-bundle/service-ca.crt",
},
{
Name: "PROPAGATE_HEADERS",
Value: "Authorization,Intuit_tid",
Expand Down Expand Up @@ -311,9 +337,27 @@ var _ = Describe("Inference Graph controller test", func() {
Drop: []v1.Capability{v1.Capability("ALL")},
},
},
VolumeMounts: []v1.VolumeMount{
{
Name: "openshift-service-ca-bundle",
MountPath: "/etc/odh/openshift-service-ca-bundle",
},
},
},
},
AutomountServiceAccountToken: proto.Bool(false),
Volumes: []v1.Volume{
{
Name: "openshift-service-ca-bundle",
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{
Name: constants.OpenShiftServiceCaConfigMapName,
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -433,6 +477,10 @@ var _ = Describe("Inference Graph controller test", func() {
{
Image: "kserve/router:v0.10.0",
Env: []v1.EnvVar{
{
Name: "SSL_CERT_FILE",
Value: "/etc/odh/openshift-service-ca-bundle/service-ca.crt",
Jooho marked this conversation as resolved.
Show resolved Hide resolved
},
{
Name: "PROPAGATE_HEADERS",
Value: "Authorization,Intuit_tid",
Expand Down Expand Up @@ -461,6 +509,12 @@ var _ = Describe("Inference Graph controller test", func() {
Drop: []v1.Capability{v1.Capability("ALL")},
},
},
VolumeMounts: []v1.VolumeMount{
{
Name: "openshift-service-ca-bundle",
MountPath: "/etc/odh/openshift-service-ca-bundle",
},
},
},
},
Affinity: &v1.Affinity{
Expand All @@ -487,6 +541,18 @@ var _ = Describe("Inference Graph controller test", func() {
},
},
AutomountServiceAccountToken: proto.Bool(false),
Volumes: []v1.Volume{
{
Name: "openshift-service-ca-bundle",
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{
Name: constants.OpenShiftServiceCaConfigMapName,
},
},
},
},
},
},
},
},
Expand Down
34 changes: 29 additions & 5 deletions pkg/controller/v1alpha1/inferencegraph/knative_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,30 @@ func createKnativeService(componentMeta metav1.ObjectMeta, graph *v1alpha1api.In
Drop: []v1.Capability{v1.Capability("ALL")},
},
},
VolumeMounts: []v1.VolumeMount{
{
Name: "openshift-service-ca-bundle",
Jooho marked this conversation as resolved.
Show resolved Hide resolved
MountPath: "/etc/odh/openshift-service-ca-bundle",
},
},
Env: []v1.EnvVar{
{
Name: "SSL_CERT_FILE",
Value: "/etc/odh/openshift-service-ca-bundle/service-ca.crt",
},
},
},
},
Volumes: []v1.Volume{
{
Name: "openshift-service-ca-bundle",
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{
Name: constants.OpenShiftServiceCaConfigMapName,
},
},
},
},
},
Affinity: graph.Spec.Affinity,
Expand All @@ -217,12 +241,12 @@ func createKnativeService(componentMeta metav1.ObjectMeta, graph *v1alpha1api.In
// Only adding this env variable "PROPAGATE_HEADERS" if router's headers config has the key "propagate"
value, exists := config.Headers["propagate"]
if exists {
service.Spec.ConfigurationSpec.Template.Spec.PodSpec.Containers[0].Env = []v1.EnvVar{
{
Name: constants.RouterHeadersPropagateEnvVar,
Value: strings.Join(value, ","),
},
propagateEnv := v1.EnvVar{
Name: constants.RouterHeadersPropagateEnvVar,
Value: strings.Join(value, ","),
}

service.Spec.ConfigurationSpec.Template.Spec.PodSpec.Containers[0].Env = append(service.Spec.ConfigurationSpec.Template.Spec.PodSpec.Containers[0].Env, propagateEnv)
}
return service
}
Expand Down
Loading