refactor(k8s): 🔧 Replace Pod with Deployment for runner instances
Some checks failed
Go Tests / go-tests (push) Failing after 1m2s
Some checks failed
Go Tests / go-tests (push) Failing after 1m2s
Changes the runner infrastructure from single Pods to Deployments for improved reliability and management: - Adds restart policy configuration - Improves container and volume naming conventions - Maintains single replica to ensure one runner instance - Sets up proper label selectors for deployment management
This commit is contained in:
parent
8c4da952e7
commit
f92a4a7c06
1 changed files with 38 additions and 24 deletions
|
|
@ -29,11 +29,13 @@ import (
|
|||
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/config"
|
||||
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/internal/spec"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
execution "github.com/cloudbase/garm-provider-common/execution/v0.1.0"
|
||||
"github.com/cloudbase/garm-provider-common/params"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
var Version = "v0.0.0-unknown"
|
||||
|
|
@ -90,42 +92,54 @@ func (a *edgeConnectProvider) CreateInstance(ctx context.Context, bootstrapParam
|
|||
|
||||
envs := spec.GetRunnerEnvs(gitHubScopeDetails, bootstrapParams)
|
||||
|
||||
podv1 := corev1.Pod{
|
||||
deployment := appsv1.Deployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: "v1",
|
||||
Kind: "Deployment",
|
||||
APIVersion: "apps/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: instancename,
|
||||
Labels: map[string]string{"run": instancename},
|
||||
Labels: map[string]string{"app": instancename},
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: ptr.To(int32(1)),
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{"app": instancename},
|
||||
},
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"app": instancename},
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
RestartPolicy: corev1.RestartPolicyNever,
|
||||
Containers: []corev1.Container{
|
||||
corev1.Container{
|
||||
Name: "mganter-test",
|
||||
{
|
||||
Name: "runner",
|
||||
Image: "edp.buildth.ing/devfw-cicd/garm-act-runner:1",
|
||||
ImagePullPolicy: "Always",
|
||||
Env: envs,
|
||||
VolumeMounts: []corev1.VolumeMount{
|
||||
corev1.VolumeMount{
|
||||
{
|
||||
Name: "runner-dir",
|
||||
MountPath: "/runner",
|
||||
Name: "cache-volume",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Volumes: []corev1.Volume{
|
||||
corev1.Volume{
|
||||
Name: "cache-volume",
|
||||
{
|
||||
Name: "runner-dir",
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
EmptyDir: &corev1.EmptyDirVolumeSource{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
podjson, err := json.Marshal(podv1)
|
||||
manifest, err := json.Marshal(deployment)
|
||||
if err != nil {
|
||||
return params.ProviderInstance{}, err
|
||||
}
|
||||
|
|
@ -156,7 +170,7 @@ func (a *edgeConnectProvider) CreateInstance(ctx context.Context, bootstrapParam
|
|||
Name: "EU.small",
|
||||
},
|
||||
DeploymentGenerator: "kubernetes-basic",
|
||||
DeploymentManifest: string(podjson),
|
||||
DeploymentManifest: string(manifest),
|
||||
RequiredOutboundConnections: []edgeconnect.SecurityRule{
|
||||
edgeconnect.SecurityRule{
|
||||
PortRangeMax: 65535,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue