Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0d8875

Browse files
Merge pull request itayankri#74 from itayankri/split-replicas-and-min-replicas
Improved deployment templating
2 parents e51dca3 + d5f9ef0 commit c0d8875

File tree

4 files changed

+50
-51
lines changed

4 files changed

+50
-51
lines changed

‎api/v1alpha1/osrmcluster_types.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ type ProfilesSpec []*ProfileSpec
9595
type ProfileSpec struct {
9696
Name string `json:"name,omitempty"`
9797
EndpointName string `json:"endpointName,omitempty"`
98+
Replicas *int32 `json:"replicas,omitempty"`
9899
InternalEndpoint *string `json:"internalEndpoint,omitempty"`
99100
OSRMProfile *string `json:"osrmProfile,omitempty"`
100101
MinReplicas *int32 `json:"minReplicas,omitempty"`

‎config/crd/bases/osrm.itayankri_osrmclusters.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ spec:
125125
type: string
126126
osrmProfile:
127127
type: string
128+
replicas:
129+
format: int32
130+
type: integer
128131
resources:
129132
description: ResourceRequirements describes the compute resource
130133
requirements.

‎config/manager/kustomization.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ kind: Kustomization
1313
images:
1414
- name: controller
1515
newName: itayankri/osrm-operator
16-
newTag: 2dfd930
16+
newTag: 2db8500

‎internal/resource/deployment.go‎

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -44,64 +44,59 @@ func (builder *DeploymentBuilder) Update(object client.Object, siblings []runtim
4444
deployment := object.(*appsv1.Deployment)
4545
pbfFileName := builder.Instance.Spec.GetPbfFileName()
4646
osrmFileName := strings.ReplaceAll(pbfFileName, "osm.pbf", "osrm")
47-
profileSpec := getProfileSpec(builder.profile.Name, builder.Instance)
47+
labelSelector := map[string]string{
48+
"app": name,
49+
}
4850

4951
deployment.ObjectMeta.Labels = metadata.GetLabels(builder.Instance, metadata.ComponentLabelProfile)
52+
deployment.Spec.Selector = &metav1.LabelSelector{
53+
MatchLabels: labelSelector,
54+
}
5055

51-
deployment.Spec = appsv1.DeploymentSpec{
52-
Replicas: profileSpec.MinReplicas,
53-
Selector: &metav1.LabelSelector{
54-
MatchLabels: map[string]string{
55-
"app": name,
56-
},
56+
deployment.Spec.Template = corev1.PodTemplateSpec{
57+
ObjectMeta: metav1.ObjectMeta{
58+
Labels: labelSelector,
5759
},
58-
Template: corev1.PodTemplateSpec{
59-
ObjectMeta: metav1.ObjectMeta{
60-
Labels: map[string]string{
61-
"app": name,
62-
},
63-
},
64-
Spec: corev1.PodSpec{
65-
Containers: []corev1.Container{
66-
{
67-
Name: osrmContainerName,
68-
Image: builder.Instance.Spec.GetImage(),
69-
Ports: []corev1.ContainerPort{
70-
{
71-
ContainerPort: 5000,
72-
},
60+
Spec: corev1.PodSpec{
61+
Containers: []corev1.Container{
62+
{
63+
Name: osrmContainerName,
64+
Image: builder.Instance.Spec.GetImage(),
65+
Ports: []corev1.ContainerPort{
66+
{
67+
ContainerPort: 5000,
7368
},
74-
Resources: *builder.profile.GetResources(),
75-
Command: []string{
76-
"/bin/sh",
77-
"-c",
78-
},
79-
Args: []string{
80-
fmt.Sprintf(`
81-
cd %s/%s && \
82-
osrm-routed %s --algorithm mld --max-matching-size 21474836
83-
`,
84-
osrmDataPath,
85-
osrmCustomizedData,
86-
osrmFileName,
87-
),
88-
},
89-
VolumeMounts: []corev1.VolumeMount{
90-
{
91-
Name: osrmDataVolumeName,
92-
MountPath: osrmDataPath,
93-
},
69+
},
70+
Resources: *builder.profile.GetResources(),
71+
Command: []string{
72+
"/bin/sh",
73+
"-c",
74+
},
75+
Args: []string{
76+
fmt.Sprintf(`
77+
cd %s/%s && \
78+
osrm-routed %s --algorithm mld --max-matching-size 21474836
79+
`,
80+
osrmDataPath,
81+
osrmCustomizedData,
82+
osrmFileName,
83+
),
84+
},
85+
VolumeMounts: []corev1.VolumeMount{
86+
{
87+
Name: osrmDataVolumeName,
88+
MountPath: osrmDataPath,
9489
},
9590
},
9691
},
97-
Volumes: []corev1.Volume{
98-
{
99-
Name: osrmDataVolumeName,
100-
VolumeSource: corev1.VolumeSource{
101-
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
102-
ClaimName: builder.Instance.ChildResourceName(builder.profile.Name, PersistentVolumeClaimSuffix),
103-
ReadOnly: true,
104-
},
92+
},
93+
Volumes: []corev1.Volume{
94+
{
95+
Name: osrmDataVolumeName,
96+
VolumeSource: corev1.VolumeSource{
97+
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
98+
ClaimName: builder.Instance.ChildResourceName(builder.profile.Name, PersistentVolumeClaimSuffix),
99+
ReadOnly: true,
105100
},
106101
},
107102
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /