feat(k8s): allow to change exposed app port
Signed-off-by: Pascal Sthamer <10992664+P4sca1@users.noreply.github.com>
This commit is contained in:
@@ -996,6 +996,10 @@ func deployK8sWorker(image string, identifier string, env []string) error {
|
|||||||
env = append(env, fmt.Sprintf("SHUFFLE_USE_GHCR_OVERRIDE_FOR_AUTODEPLOY=%s", os.Getenv("SHUFFLE_USE_GHCR_OVERRIDE_FOR_AUTODEPLOY")))
|
env = append(env, fmt.Sprintf("SHUFFLE_USE_GHCR_OVERRIDE_FOR_AUTODEPLOY=%s", os.Getenv("SHUFFLE_USE_GHCR_OVERRIDE_FOR_AUTODEPLOY")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(os.Getenv("SHUFFLE_APP_EXPOSED_PORT")) > 0 {
|
||||||
|
env = append(env, fmt.Sprintf("SHUFFLE_APP_EXPOSED_PORT=%s", os.Getenv("SHUFFLE_APP_EXPOSED_PORT")))
|
||||||
|
}
|
||||||
|
|
||||||
if len(appServiceAccountName) > 0 {
|
if len(appServiceAccountName) > 0 {
|
||||||
env = append(env, fmt.Sprintf("SHUFFLE_APP_SERVICE_ACCOUNT_NAME=%s", appServiceAccountName))
|
env = append(env, fmt.Sprintf("SHUFFLE_APP_SERVICE_ACCOUNT_NAME=%s", appServiceAccountName))
|
||||||
}
|
}
|
||||||
@@ -1271,7 +1275,6 @@ func deployWorker(image string, identifier string, env []string, executionReques
|
|||||||
Resources: container.Resources{},
|
Resources: container.Resources{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is just to test the mounting locally so
|
// This is just to test the mounting locally so
|
||||||
// I can control from what source I'm mounting
|
// I can control from what source I'm mounting
|
||||||
// the certs to. Default behaviour is:
|
// the certs to. Default behaviour is:
|
||||||
|
|||||||
@@ -399,6 +399,11 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
kubernetesNamespace = "default"
|
kubernetesNamespace = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployport, err := strconv.Atoi(os.Getenv("SHUFFLE_APP_EXPOSED_PORT"))
|
||||||
|
if err != nil {
|
||||||
|
deployport = 80
|
||||||
|
}
|
||||||
|
|
||||||
envMap := make(map[string]string)
|
envMap := make(map[string]string)
|
||||||
for _, envStr := range env {
|
for _, envStr := range env {
|
||||||
parts := strings.SplitN(envStr, "=", 2)
|
parts := strings.SplitN(envStr, "=", 2)
|
||||||
@@ -408,9 +413,7 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add to env
|
// add to env
|
||||||
// fmt.Sprintf("SHUFFLE_APP_EXPOSED_PORT=%d", deployport),
|
envMap["SHUFFLE_APP_EXPOSED_PORT"] = strconv.Itoa(deployport)
|
||||||
// fmt.Sprintf("SHUFFLE_SWARM_CONFIG=%s", os.Getenv("SHUFFLE_SWARM_CONFIG")),
|
|
||||||
envMap["SHUFFLE_APP_EXPOSED_PORT"] = "80"
|
|
||||||
envMap["SHUFFLE_SWARM_CONFIG"] = os.Getenv("SHUFFLE_SWARM_CONFIG")
|
envMap["SHUFFLE_SWARM_CONFIG"] = os.Getenv("SHUFFLE_SWARM_CONFIG")
|
||||||
envMap["BASE_URL"] = "http://shuffle-workers:33333"
|
envMap["BASE_URL"] = "http://shuffle-workers:33333"
|
||||||
|
|
||||||
@@ -599,6 +602,12 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
Name: value,
|
Name: value,
|
||||||
Image: image,
|
Image: image,
|
||||||
Env: buildEnvVars(envMap),
|
Env: buildEnvVars(envMap),
|
||||||
|
Ports: []corev1.ContainerPort{
|
||||||
|
{
|
||||||
|
Protocol: "TCP",
|
||||||
|
ContainerPort: int32(deployport),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DNSPolicy: corev1.DNSClusterFirst,
|
DNSPolicy: corev1.DNSClusterFirst,
|
||||||
@@ -614,7 +623,6 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// kubectl expose deployment {podName} --type=NodePort --port=80 --target-port=80
|
|
||||||
service := &corev1.Service{
|
service := &corev1.Service{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
@@ -626,7 +634,7 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
{
|
{
|
||||||
Protocol: "TCP",
|
Protocol: "TCP",
|
||||||
Port: 80,
|
Port: 80,
|
||||||
TargetPort: intstr.FromInt(80),
|
TargetPort: intstr.FromInt(deployport),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Type: corev1.ServiceTypeNodePort,
|
Type: corev1.ServiceTypeNodePort,
|
||||||
@@ -940,9 +948,9 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
|||||||
}
|
}
|
||||||
|
|
||||||
builtMount := mount.Mount{
|
builtMount := mount.Mount{
|
||||||
Type: mount.TypeBind,
|
Type: mount.TypeBind,
|
||||||
Source: sourceFolder,
|
Source: sourceFolder,
|
||||||
Target: destinationFolder,
|
Target: destinationFolder,
|
||||||
ReadOnly: readOnly,
|
ReadOnly: readOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1859,12 +1867,12 @@ func executionInit(workflowExecution shuffle.WorkflowExecution) error {
|
|||||||
// 2. Only ONE action
|
// 2. Only ONE action
|
||||||
// 3. Every predefined result having result.Action.Category == "rerun"
|
// 3. Every predefined result having result.Action.Category == "rerun"
|
||||||
/*
|
/*
|
||||||
if len(workflowExecution.Workflow.Actions) == 1 && len(workflowExecution.Results) > 0 {
|
if len(workflowExecution.Workflow.Actions) == 1 && len(workflowExecution.Results) > 0 {
|
||||||
finished := shuffle.ValidateFinished(ctx, extra, workflowExecution)
|
finished := shuffle.ValidateFinished(ctx, extra, workflowExecution)
|
||||||
if finished {
|
if finished {
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nextActions = append(nextActions, startAction)
|
nextActions = append(nextActions, startAction)
|
||||||
@@ -1954,7 +1962,6 @@ func executionInit(workflowExecution shuffle.WorkflowExecution) error {
|
|||||||
//log.Printf("Successfully downloaded and built %s", image)
|
//log.Printf("Successfully downloaded and built %s", image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
visited := []string{}
|
visited := []string{}
|
||||||
executed := []string{}
|
executed := []string{}
|
||||||
environments := []string{}
|
environments := []string{}
|
||||||
@@ -3905,7 +3912,6 @@ func checkStandaloneRun() {
|
|||||||
|
|
||||||
log.Printf("\n\n\n[DEBUG] Finished resetting execution %s. Body: %s. Starting execution.\n\n\n", newresp.Status, string(body))
|
log.Printf("\n\n\n[DEBUG] Finished resetting execution %s. Body: %s. Starting execution.\n\n\n", newresp.Status, string(body))
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial loop etc
|
// Initial loop etc
|
||||||
|
|||||||
Reference in New Issue
Block a user