@@ -3,6 +3,7 @@ package oapi
3
3
import (
4
4
"fmt"
5
5
"path"
6
+ "strings"
6
7
7
8
configv1 "github.com/openshift/api/config/v1"
8
9
hyperv1 "github.com/openshift/hypershift/api/hypershift/v1beta1"
40
41
oauthVolumeEtcdClientCert ().Name : "/etc/kubernetes/certs/etcd-client" ,
41
42
common .VolumeTotalClientCA ().Name : "/etc/kubernetes/certs/client-ca" ,
42
43
},
44
+ oauthKonnectivityProxyContainer ().Name : {
45
+ oauthVolumeKubeconfig ().Name : "/etc/kubernetes/secrets/kubeconfig" ,
46
+ oauthVolumeKonnectivityProxyCert ().Name : "/etc/konnectivity/proxy-client" ,
47
+ oauthVolumeKonnectivityProxyCA ().Name : "/etc/konnectivity/proxy-ca" ,
48
+ },
43
49
}
44
50
oauthAuditWebhookConfigFileVolumeMount = util.PodVolumeMounts {
45
51
oauthContainerMain ().Name : {
@@ -55,9 +61,18 @@ func openShiftOAuthAPIServerLabels() map[string]string {
55
61
}
56
62
}
57
63
58
- func ReconcileOAuthAPIServerDeployment (deployment * appsv1.Deployment , ownerRef config.OwnerRef , auditConfig * corev1.ConfigMap , p * OAuthDeploymentParams , platformType hyperv1.PlatformType ) error {
64
+ func ReconcileOAuthAPIServerDeployment (deployment * appsv1.Deployment ,
65
+ ownerRef config.OwnerRef ,
66
+ auditConfig * corev1.ConfigMap ,
67
+ p * OAuthDeploymentParams ,
68
+ platformType hyperv1.PlatformType ) error {
59
69
ownerRef .ApplyTo (deployment )
60
70
71
+ etcdHost , err := util .HostFromURL (p .EtcdURL )
72
+ if err != nil {
73
+ return err
74
+ }
75
+
61
76
// preserve existing resource requirements for main oauth apiserver container
62
77
mainContainer := util .FindContainer (oauthContainerMain ().Name , deployment .Spec .Template .Spec .Containers )
63
78
if mainContainer != nil {
@@ -95,7 +110,8 @@ func ReconcileOAuthAPIServerDeployment(deployment *appsv1.Deployment, ownerRef c
95
110
AutomountServiceAccountToken : ptr .To (false ),
96
111
TerminationGracePeriodSeconds : ptr.To [int64 ](120 ),
97
112
Containers : []corev1.Container {
98
- util .BuildContainer (oauthContainerMain (), buildOAuthContainerMain (p )),
113
+ util .BuildContainer (oauthContainerMain (), buildOAuthContainerMain (p , etcdHost )),
114
+ util .BuildContainer (oauthKonnectivityProxyContainer (), buildOAuthKonnectivityProxyContainer (p .KonnectivityProxyImage )),
99
115
},
100
116
Volumes : []corev1.Volume {
101
117
util .BuildVolume (oauthVolumeWorkLogs (), buildOAuthVolumeWorkLogs ),
@@ -106,6 +122,8 @@ func ReconcileOAuthAPIServerDeployment(deployment *appsv1.Deployment, ownerRef c
106
122
util .BuildVolume (oauthVolumeServingCert (), buildOAuthVolumeServingCert ),
107
123
util .BuildVolume (oauthVolumeEtcdClientCert (), buildOAuthVolumeEtcdClientCert ),
108
124
util .BuildVolume (common .VolumeTotalClientCA (), common .BuildVolumeTotalClientCA ),
125
+ util .BuildVolume (oauthVolumeKonnectivityProxyCert (), buildOAuthVolumeKonnectivityProxyCert ),
126
+ util .BuildVolume (oauthVolumeKonnectivityProxyCA (), buildOAuthVolumeKonnectivityProxyCA ),
109
127
},
110
128
}
111
129
@@ -147,7 +165,13 @@ func oauthContainerMain() *corev1.Container {
147
165
}
148
166
}
149
167
150
- func buildOAuthContainerMain (p * OAuthDeploymentParams ) func (c * corev1.Container ) {
168
+ func oauthKonnectivityProxyContainer () * corev1.Container {
169
+ return & corev1.Container {
170
+ Name : "konnectivity-proxy" ,
171
+ }
172
+ }
173
+
174
+ func buildOAuthContainerMain (p * OAuthDeploymentParams , etcdHost string ) func (c * corev1.Container ) {
151
175
return func (c * corev1.Container ) {
152
176
cpath := func (volume , file string ) string {
153
177
return path .Join (oauthVolumeMounts .Path (c .Name , volume ), file )
@@ -199,6 +223,41 @@ func buildOAuthContainerMain(p *OAuthDeploymentParams) func(c *corev1.Container)
199
223
corev1 .ResourceCPU : resource .MustParse ("10m" ),
200
224
},
201
225
}
226
+ c .Env = append (c .Env , []corev1.EnvVar {
227
+ {
228
+ Name : "HTTP_PROXY" ,
229
+ Value : "socks5://127.0.0.1:8090" ,
230
+ },
231
+ {
232
+ Name : "HTTPS_PROXY" ,
233
+ Value : "socks5://127.0.0.1:8090" ,
234
+ },
235
+ {
236
+ Name : "NO_PROXY" ,
237
+ Value : strings .Join ([]string {
238
+ manifests .KubeAPIServerService ("" ).Name ,
239
+ etcdHost ,
240
+ config .AuditWebhookService ,
241
+ }, "," ),
242
+ },
243
+ }... )
244
+ }
245
+ }
246
+
247
+ func buildOAuthKonnectivityProxyContainer (image string ) func (c * corev1.Container ) {
248
+ return func (c * corev1.Container ) {
249
+ c .Image = image
250
+ c .Command = []string {"/usr/bin/control-plane-operator" , "konnectivity-socks5-proxy" }
251
+ c .Args = []string {"run" , "--resolve-from-guest-cluster-dns=true" }
252
+ c .Env = []corev1.EnvVar {{
253
+ Name : "KUBECONFIG" ,
254
+ Value : fmt .Sprintf ("%s/kubeconfig" , volumeMounts .Path (c .Name , oauthVolumeKubeconfig ().Name )),
255
+ }}
256
+ c .Resources .Requests = corev1.ResourceList {
257
+ corev1 .ResourceCPU : resource .MustParse ("10m" ),
258
+ corev1 .ResourceMemory : resource .MustParse ("10Mi" ),
259
+ }
260
+ c .VolumeMounts = oauthVolumeMounts .ContainerMounts (c .Name )
202
261
}
203
262
}
204
263
@@ -297,6 +356,29 @@ func oauthAuditWebhookConfigFile() string {
297
356
return path .Join (cfgDir , hyperv1 .AuditWebhookKubeconfigKey )
298
357
}
299
358
359
+ func oauthVolumeKonnectivityProxyCert () * corev1.Volume {
360
+ return & corev1.Volume {
361
+ Name : "oauth-konnectivity-proxy-cert" ,
362
+ }
363
+ }
364
+
365
+ func oauthVolumeKonnectivityProxyCA () * corev1.Volume {
366
+ return & corev1.Volume {
367
+ Name : "oauth-konnectivity-proxy-ca" ,
368
+ }
369
+ }
370
+
371
+ func buildOAuthVolumeKonnectivityProxyCert (v * corev1.Volume ) {
372
+ v .Secret = & corev1.SecretVolumeSource {}
373
+ v .Secret .SecretName = manifests .KonnectivityClientSecret ("" ).Name
374
+ v .Secret .DefaultMode = ptr.To [int32 ](0640 )
375
+ }
376
+
377
+ func buildOAuthVolumeKonnectivityProxyCA (v * corev1.Volume ) {
378
+ v .ConfigMap = & corev1.ConfigMapVolumeSource {}
379
+ v .ConfigMap .Name = manifests .KonnectivityCAConfigMap ("" ).Name
380
+ }
381
+
300
382
func buildOAuthVolumeEtcdClientCert (v * corev1.Volume ) {
301
383
v .Secret = & corev1.SecretVolumeSource {}
302
384
v .Secret .SecretName = manifests .EtcdClientSecret ("" ).Name
0 commit comments