-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
029a403
commit 8e831d9
Showing
20 changed files
with
518 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- | ||
description: LoadBalancer IP address management | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# LoadBalancer IP address management | ||
|
||
## Understanding $[prodname] LoadBalancer IP address management | ||
|
||
You might want to utilize Service of type LoadBalancer in your cluster to provide stable long-lasting IP address to access your deployed application. | ||
$[prodname] can help you with providing and managing IP addresses to your Services in your cluster. $[prodname] comes with LoadBalancer IPAM deployed as part of $[prodname] Kube-controllers. | ||
|
||
### Before you begin... | ||
|
||
Ensure that you have a cluster with $[prodname] installed, and kube-controllers configured and running. | ||
|
||
### IP Pool for Service of type LoadBalancer | ||
|
||
$[prodname] does not automatically provide default IP Pool for LoadBalancer IP address management. You will need to create an IP Pool with `allowedUses` LoadBalancer for $[prodname] to start assigning Service IPs. | ||
|
||
```yaml | ||
apiVersion: projectcalico.org/v3 | ||
kind: IPPool | ||
metadata: | ||
name: loadbalancerIPPool | ||
spec: | ||
cidr: 192.210.0.0/20 | ||
blockSize: 24 | ||
natOutgoing: true | ||
disabled: false | ||
assignmentMode: Automatic | ||
allowedUses: | ||
- LoadBalancer | ||
``` | ||
:::note | ||
You can create multiple IP Pools with allowedUses LoadBalancer as long as there are no CIDR conflicts. By setting assignmentMode to Manual you can reserve the IP Pool for manual assignments only. Explore more about [manual assignment](#manual-service-ip-address-assignment) | ||
::: | ||
### Automatic Service IP address assignment | ||
When you create Service of type LoadBalancer $[prodname] kube-controller will automatically detect the new Service and assign an IP address from available IP Pool. If no address is available, the Service will remain in pending state until an address is available. | ||
```yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: service-loadbalancer | ||
spec: | ||
selector: | ||
app: nginx | ||
ports: | ||
- port: 80 | ||
targetPort: 80 | ||
name: default | ||
type: LoadBalancer | ||
``` | ||
### Manual Service IP address assignment | ||
There are cases where you would like to be more specific about what IP address $[prodname] assigns to your Service. With annotations, you can specify how IP address should be assigned. The annotations can be added and removed as needed during the lifetime of the Service. When you remove an annotation $[prodname] kube-controller will check if the assigned IP is still valid and potentially assign a new one. | ||
#### Specify IP Pool | ||
##### IPv4 Pool | ||
Annotate the Service with projectcalico.org/ipv4pools to assign IP address from the selected IP Pools. You can specify multiple IP Pools in this annotation, $[prodname] will pick an available IP address to assign. | ||
``` | ||
"projectcalico.org/ipv4pools": '["loadBalancerIPv4Pool"]' | ||
``` | ||
##### IPv6 Pool | ||
Annotate the Service with projectcalico.org/ipv6pools to assign IP address from the selected IP Pools. You can specify multiple IP Pools in this annotation, $[prodname] will pick an available IP address to assign. | ||
``` | ||
"projectcalico.org/ipv6pools": '["loadBalancerIPv6Pool"]' | ||
``` | ||
:::note | ||
In dual-stack environment you don't have to specify both annotations. If IP Pool was not specified for IP family, $[prodname] will automatically assign available IP address from available IP Pool | ||
::: | ||
#### Specifying IP address | ||
Annotate the Service with projectcalico.org/loadBalancerIPs to assign specific IP address. The address must be available otherwise $[prodname] will not be able to assign the address. Currently you can only specify one IPv4 and one IPv6 address at the same time. | ||
``` | ||
"projectcalico.org/loadBalancerIPs": '["x.x.x.x"]' | ||
``` | ||
:::note | ||
If Service contains "projectcalico.org/loadBalancerIPs" annotation and either "projectcalico.org/ipv6pools" or "projectcalico.org/ipv4pools" are present, $[prodname] will favour projectcalico.org/loadBalancerIPs annotation and try to assign that IP address. There is no fall back to an IP Pool if the specified address is not available. | ||
::: | ||
### Manage LoadBalancer kube-controller assignment mode | ||
In certain cases you might not wish for $[prodname] to automatically assign IP addresses to your Service. This can be useful in case you have multiple Service IPAM solutions in your cluster. | ||
LoadBalancer kube-controller is able to operate in two distinct modes ```Automatic``` in which $[prodname] assigns IP address to each Service in your cluster and ```RequestedServicesOnly``` in which $[prodname] only assigns IP addresses to Service with annotations mentioned above. | ||
You can change the mode at any point, but note that switching to ```RequestedServicesOnly``` will unassign any addresses from Services that do not contain the above annotations. | ||
|
||
```bash | ||
kubectl patch kubecontrollersconfiguration default --patch '{"spec": {"controllers":{"loadBalancer":{"AssignIPs": "RequestedServicesOnly"}}}}' | ||
``` | ||
|
||
### Additional resources | ||
|
||
Calico LoadBalancer IP address management works in conjunction with other $[prodname] components. $[prodname] kube-controllers provides only the IP address management, to advertise LoadBalancer IPs you will have to update your BGP configuration. You can find out more information at: | ||
* [Advertising Kubernetes service IP addresses](../../networking/configuring/advertise-service-ips.mdx#advertise-service-load-balancer-ip-addresses) | ||
* [IP Pool](../../reference/resources/ippool.mdx) | ||
* [Kube-controllers configuration](../../reference/resources/kubecontrollersconfig.mdx#loadbalancercontroller) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.