Skip to content

Commit

Permalink
Add ExternalName to ServiceSpec
Browse files Browse the repository at this point in the history
ExternalName allows kubedns to return CNAME records for external
services. No proxying is involved.

See original issue at
kubernetes#13748

Feature tracking at
kubernetes/enhancements#33
  • Loading branch information
Rudi Chiarito committed Aug 18, 2016
1 parent d576486 commit 8e202ad
Show file tree
Hide file tree
Showing 15 changed files with 22,216 additions and 21,970 deletions.
10 changes: 7 additions & 3 deletions api/swagger-spec/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19247,15 +19247,15 @@
},
"selector": {
"type": "object",
"description": "This service will route traffic to pods having labels matching this selector. Label keys and values that must match in order to receive traffic for this service. If not specified, endpoints must be manually specified and the system will not automatically manage them. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview"
"description": "Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview"
},
"clusterIP": {
"type": "string",
"description": "ClusterIP is usually assigned by the master and is the IP address of the service. If specified, it will be allocated to the service if it is unused or else creation of the service will fail. Valid values are None, empty string (\"\"), or a valid IP address. 'None' can be specified for a headless service when proxying is not required. Cannot be updated. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies"
"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. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies"
},
"type": {
"type": "string",
"description": "Type of exposed service. Must be ClusterIP, NodePort, or LoadBalancer. Defaults to ClusterIP. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#external-services"
"description": "type determines how to expose the service. Defaults to ClusterIP. For types other than ExternalName, it only applies if clusterIP != \"None\". Valid options are ClusterIP, NodePort, LoadBalancer, and ExternalName. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview"
},
"externalIPs": {
"type": "array",
Expand Down Expand Up @@ -19285,6 +19285,10 @@
"type": "string"
},
"description": "If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\" More info: http://releases.k8s.io/HEAD/docs/user-guide/services-firewalls.md"
},
"externalName": {
"type": "string",
"description": "externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid DNS name and requires Type to be ExternalName."
}
}
},
Expand Down
15 changes: 11 additions & 4 deletions docs/api-reference/v1/definitions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7892,21 +7892,21 @@ <h3 id="_v1_servicespec">v1.ServiceSpec</h3>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">This service will route traffic to pods having labels matching this selector. Label keys and values that must match in order to receive traffic for this service. If not specified, endpoints must be manually specified and the system will not automatically manage them. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview">http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview">http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">object</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">clusterIP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ClusterIP is usually assigned by the master and is the IP address of the service. If specified, it will be allocated to the service if it is unused or else creation of the service will fail. Valid values are None, empty string (""), or a valid IP address. <em>None</em> can be specified for a headless service when proxying is not required. Cannot be updated. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies">http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">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. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies">http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">type</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Type of exposed service. Must be ClusterIP, NodePort, or LoadBalancer. Defaults to ClusterIP. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/services.md#external-services">http://releases.k8s.io/HEAD/docs/user-guide/services.md#external-services</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">type determines how to expose the service. Defaults to ClusterIP. For types other than ExternalName, it only applies if clusterIP != "None". Valid options are ClusterIP, NodePort, LoadBalancer, and ExternalName. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview">http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
Expand Down Expand Up @@ -7946,6 +7946,13 @@ <h3 id="_v1_servicespec">v1.ServiceSpec</h3>
<td class="tableblock halign-left valign-top"><p class="tableblock">string array</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">externalName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid DNS name and requires Type to be ExternalName.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -8167,7 +8174,7 @@ <h3 id="_any">any</h3>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-08-17 09:55:44 UTC
Last updated 2016-08-18 06:58:40 UTC
</div>
</div>
</body>
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ func IsServiceIPSet(service *Service) bool {

// this function aims to check if the service's cluster IP is requested or not
func IsServiceIPRequested(service *Service) bool {
// ExternalName services are CNAME aliases to external ones. Ignore the IP.
if service.Spec.Type == ServiceTypeExternalName {
return false
}
return service.Spec.ClusterIP == ""
}

Expand Down
Loading

0 comments on commit 8e202ad

Please sign in to comment.