|
9 | 9 | routev1 "github.com/openshift/api/route/v1"
|
10 | 10 | rayv1api "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
|
11 | 11 | corev1 "k8s.io/api/core/v1"
|
| 12 | + "k8s.io/apimachinery/pkg/types" |
12 | 13 | "sigs.k8s.io/controller-runtime/pkg/client"
|
13 | 14 | )
|
14 | 15 |
|
@@ -139,15 +140,28 @@ func mtlsPatch(rayCluster *rayv1api.RayCluster, patches []patchOperation, initHe
|
139 | 140 | }
|
140 | 141 | svcDomain := rayCluster.Name + "-head-svc." + rayCluster.Namespace + ".svc"
|
141 | 142 | secretName := `ca-secret-` + rayCluster.Name
|
| 143 | + fmt.Println("Start") |
| 144 | + domain, err := getDomainName() |
| 145 | + if err != nil { |
| 146 | + fmt.Printf(err.Error()) |
| 147 | + } |
| 148 | + fmt.Println("mid") |
| 149 | + fmt.Printf(domain) |
| 150 | + fmt.Println("End") |
142 | 151 | if !initHeadExists {
|
143 | 152 | if isLocalInteractive {
|
| 153 | + domain, err := getDomainName() |
| 154 | + if err != nil { |
| 155 | + return nil, err |
| 156 | + } |
| 157 | + rayClientRoute := "rayclient-" + rayCluster.Name + domain |
144 | 158 | initContainerHead = corev1.Container{
|
145 | 159 | Name: "create-cert",
|
146 | 160 | Image: "quay.io/project-codeflare/ray:latest-py39-cu118",
|
147 | 161 | Command: []string{
|
148 | 162 | "sh",
|
149 | 163 | "-c",
|
150 |
| - `cd /home/ray/workspace/tls && openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj '/CN=ray-head' && printf 'authorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nsubjectAltName = @alt_names\n[alt_names]\nDNS.1 = 127.0.0.1\nDNS.2 = localhost\nDNS.3 = ${FQ_RAY_IP}\nDNS.4 = $(awk 'END{print $1}' /etc/hosts)\nDNS.5 = rayclient-` + rayCluster.Name + `-` + rayCluster.Namespace + `-head-svc.default.svc > ./domain.ext && cp /home/ray/workspace/ca/* . && openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial -extfile domain.ext`, |
| 164 | + `cd /home/ray/workspace/tls && openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj '/CN=ray-head' && printf "authorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nsubjectAltName = @alt_names\n[alt_names]\nDNS.1 = 127.0.0.1\nDNS.2 = localhost\nDNS.3 = ${FQ_RAY_IP}\nDNS.4 = $(awk 'END{print $1}' /etc/hosts)\nDNS.5 = ` + rayClientRoute + `">./domain.ext && cp /home/ray/workspace/ca/* . && openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial -extfile domain.ext`, |
151 | 165 | },
|
152 | 166 | VolumeMounts: key_volumes,
|
153 | 167 | }
|
@@ -230,7 +244,6 @@ func mtlsPatch(rayCluster *rayv1api.RayCluster, patches []patchOperation, initHe
|
230 | 244 | }
|
231 | 245 |
|
232 | 246 | if !workerHeadExists {
|
233 |
| - fmt.Println("PATCHING WORKER") |
234 | 247 | initContainerWorker := corev1.Container{
|
235 | 248 | Name: "create-cert",
|
236 | 249 | Image: "quay.io/project-codeflare/ray:latest-py39-cu118",
|
@@ -322,13 +335,18 @@ func annotationBoolVal(cluster *rayv1api.RayCluster, annotation string, defaultV
|
322 | 335 | return boolVal
|
323 | 336 | }
|
324 | 337 |
|
325 |
| -func getDomainName() string { |
| 338 | +func getDomainName() (string, error) { |
326 | 339 | consoleRoute := &routev1.Route{}
|
327 |
| - if err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: NameConsoleLink, Namespace: NamespaceConsoleLink}, consoleRoute); err != nil { |
328 |
| - fmt.Errorf("error getting console route URL %s : %w", NameConsoleLink, err) |
329 |
| - return "error" //fmt.Errorf("error getting console route URL %s : %w", NameConsoleLink, err) |
| 340 | + fmt.Println("1") |
| 341 | + fmt.Printf(client.ObjectKey{Name: NameConsoleLink, Namespace: NamespaceConsoleLink}.String()) |
| 342 | + fmt.Println("2") |
| 343 | + fmt.Printf(consoleRoute.String()) |
| 344 | + |
| 345 | + if err := k8Client.Get(context.TODO(), types.NamespacedName{Name: NameConsoleLink, Namespace: NamespaceConsoleLink}, consoleRoute); err != nil { |
| 346 | + return "error getting console route URL %s : %w", err |
330 | 347 | }
|
| 348 | + fmt.Printf("3") |
331 | 349 | domainIndex := strings.Index(consoleRoute.Spec.Host, ".")
|
332 | 350 | consoleLinkDomain := consoleRoute.Spec.Host[domainIndex+1:]
|
333 |
| - return consoleLinkDomain |
| 351 | + return consoleLinkDomain, nil |
334 | 352 | }
|
0 commit comments