Skip to content

Commit

Permalink
feat: add affinity, tolerations in template and clusterIP in service. C…
Browse files Browse the repository at this point in the history
…loses #663. (#664)

* feat: add affinity, tolerations in template and clusterIP in service

* correct order
  • Loading branch information
whynowy authored May 18, 2020
1 parent 13b38c0 commit d570157
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 11 deletions.
48 changes: 47 additions & 1 deletion api/gateway.html
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,25 @@ <h3 id="argoproj.io/v1alpha1.Service">Service
</em>
</td>
<td>
<p>The list of ports that are exposed by this service.</p>
<p>The list of ports that are exposed by this ClusterIP service.</p>
</td>
</tr>
<tr>
<td>
<code>clusterIP</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>clusterIP is the IP address of the service and is usually assigned
randomly by the master. If an address is specified manually and is not in
use by others, it will be allocated to the service; otherwise, creation
of the service will fail. This field can not be changed through updates.
Valid values are &ldquo;None&rdquo;, empty string (&ldquo;&rdquo;), or a valid IP address. &ldquo;None&rdquo;
can be specified for headless services when proxying is not required.
More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies">https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies</a></p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -769,6 +787,34 @@ <h3 id="argoproj.io/v1alpha1.Template">Template
</tr>
<tr>
<td>
<code>affinity</code></br>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#affinity-v1-core">
Kubernetes core/v1.Affinity
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>If specified, the pod&rsquo;s scheduling constraints</p>
</td>
</tr>
<tr>
<td>
<code>tolerations</code></br>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#toleration-v1-core">
[]Kubernetes core/v1.Toleration
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>If specified, the pod&rsquo;s tolerations.</p>
</td>
</tr>
<tr>
<td>
<code>spec</code></br>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#podspec-v1-core">
Expand Down
79 changes: 78 additions & 1 deletion api/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,36 @@ Description

<p>

The list of ports that are exposed by this service.
The list of ports that are exposed by this ClusterIP service.

</p>

</td>

</tr>

<tr>

<td>

<code>clusterIP</code></br> <em> string </em>

</td>

<td>

<em>(Optional)</em>

<p>

clusterIP is the IP address of the service and is usually assigned
randomly by the master. If an address is specified manually and is not
in use by others, it will be allocated to the service; otherwise,
creation of the service will fail. This field can not be changed through
updates. Valid values are “None”, empty string (“”), or a valid IP
address. “None” can be specified for headless services when proxying is
not required. More info:
<a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies">https://kubernetes.io/docs/concepts/services-networking/service/\#virtual-ips-and-service-proxies</a>

</p>

Expand Down Expand Up @@ -1524,6 +1553,54 @@ values of each field.

<td>

<code>affinity</code></br> <em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#affinity-v1-core">
Kubernetes core/v1.Affinity </a> </em>

</td>

<td>

<em>(Optional)</em>

<p>

If specified, the pod’s scheduling constraints

</p>

</td>

</tr>

<tr>

<td>

<code>tolerations</code></br> <em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#toleration-v1-core">
\[\]Kubernetes core/v1.Toleration </a> </em>

</td>

<td>

<em>(Optional)</em>

<p>

If specified, the pod’s tolerations.

</p>

</td>

</tr>

<tr>

<td>

<code>spec</code></br> <em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#podspec-v1-core">
Kubernetes core/v1.PodSpec </a> </em>
Expand Down
17 changes: 16 additions & 1 deletion api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,12 @@
"description": "Service holds the service information gateway exposes",
"type": "object",
"properties": {
"clusterIP": {
"description": "clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are \"None\", empty string (\"\"), or a valid IP address. \"None\" can be specified for headless services when proxying is not required. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
"type": "string"
},
"ports": {
"description": "The list of ports that are exposed by this service.",
"description": "The list of ports that are exposed by this ClusterIP service.",
"type": "array",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.ServicePort"
Expand Down Expand Up @@ -944,6 +948,10 @@
"description": "Template holds the information of a Gateway deployment template",
"type": "object",
"properties": {
"affinity": {
"description": "If specified, the pod's scheduling constraints",
"$ref": "#/definitions/io.k8s.api.core.v1.Affinity"
},
"container": {
"description": "Container is the main container image to run in the gateway pod",
"$ref": "#/definitions/io.k8s.api.core.v1.Container"
Expand All @@ -960,6 +968,13 @@
"description": "Spec holds the gateway deployment spec. DEPRECATED: Use Container instead.",
"$ref": "#/definitions/io.k8s.api.core.v1.PodSpec"
},
"tolerations": {
"description": "If specified, the pod's tolerations.",
"type": "array",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.Toleration"
}
},
"volumes": {
"description": "Volumes is a list of volumes that can be mounted by containers in a workflow.",
"type": "array",
Expand Down
9 changes: 6 additions & 3 deletions controllers/gateway/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ func (ctx *gatewayContext) buildServiceResource() (*corev1.Service, error) {
Name: fmt.Sprintf("%s-gateway", ctx.gateway.Name),
},
Spec: corev1.ServiceSpec{
Ports: ctx.gateway.Spec.Service.Ports,
Type: corev1.ServiceTypeClusterIP,
Selector: labels,
Ports: ctx.gateway.Spec.Service.Ports,
Type: corev1.ServiceTypeClusterIP,
ClusterIP: ctx.gateway.Spec.Service.ClusterIP,
Selector: labels,
},
}
if err := controllerscommon.SetObjectMeta(ctx.gateway, svc, v1alpha1.SchemaGroupVersionKind); err != nil {
Expand Down Expand Up @@ -144,6 +145,8 @@ func (ctx *gatewayContext) makeDeploymentSpec() (*appv1.DeploymentSpec, error) {
},
eventContainer,
},
Affinity: ctx.gateway.Spec.Template.Affinity,
Tolerations: ctx.gateway.Spec.Template.Tolerations,
Volumes: ctx.gateway.Spec.Template.Volumes,
SecurityContext: ctx.gateway.Spec.Template.SecurityContext,
},
Expand Down
30 changes: 28 additions & 2 deletions pkg/apis/gateway/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions pkg/apis/gateway/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,38 @@ type Template struct {
// Optional: Defaults to empty. See type description for default values of each field.
// +optional
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty" protobuf:"bytes,4,opt,name=securityContext"`
// If specified, the pod's scheduling constraints
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,5,opt,name=affinity"`
// If specified, the pod's tolerations.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,6,opt,name=tolerations"`
// Spec holds the gateway deployment spec.
// DEPRECATED: Use Container instead.
Spec *corev1.PodSpec `json:"spec,omitempty" protobuf:"bytes,5,opt,name=spec"`
Spec *corev1.PodSpec `json:"spec,omitempty" protobuf:"bytes,7,opt,name=spec"`
}

// Service holds the service information gateway exposes
type Service struct {
// The list of ports that are exposed by this service.
// The list of ports that are exposed by this ClusterIP service.
// +patchMergeKey=port
// +patchStrategy=merge
// +listType=map
// +listMapKey=port
// +listMapKey=protocol
Ports []corev1.ServicePort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"port" protobuf:"bytes,1,rep,name=ports"`
// clusterIP is the IP address of the service and is usually assigned
// randomly by the master. If an address is specified manually and is not in
// use by others, it will be allocated to the service; otherwise, creation
// of the service will fail. This field can not be changed through updates.
// Valid values are "None", empty string (""), or a valid IP address. "None"
// can be specified for headless services when proxying is not required.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
// +optional
ClusterIP string `json:"clusterIP,omitempty" protobuf:"bytes,2,opt,name=clusterIP"`
// Spec holds the gateway service spec.
// DEPRECATED: Use Ports to declare the ports to be exposed.
Spec *corev1.ServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
Spec *corev1.ServiceSpec `json:"spec,omitempty" protobuf:"bytes,3,opt,name=spec"`
}

type Subscribers struct {
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/gateway/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d570157

Please sign in to comment.