mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #49182 from juju-solutions/feature/increase-cidr
Automatic merge from submit-queue (batch tested with PRs 49058, 49072, 49137, 49182, 49045) Set default CIDR to /16 for Juju deployments **What this PR does / why we need it**: Increase the number of IPs on a deployment **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes https://github.com/juju-solutions/bundle-canonical-kubernetes/issues/272 **Special notes for your reviewer**: **Release note**: ```Set default CIDR to /16 for Juju deployments ```
This commit is contained in:
commit
7dc0322b0c
@ -9,7 +9,7 @@ options:
|
||||
description: The local domain for cluster dns
|
||||
service-cidr:
|
||||
type: string
|
||||
default: 10.152.183.0/24
|
||||
default: 10.152.0.0/16
|
||||
description: CIDR to user for Kubernetes services. Cannot be changed after deployment.
|
||||
allow-privileged:
|
||||
type: string
|
||||
|
@ -22,6 +22,7 @@ import shutil
|
||||
import socket
|
||||
import string
|
||||
import json
|
||||
import ipaddress
|
||||
|
||||
import charms.leadership
|
||||
|
||||
@ -783,18 +784,18 @@ def create_kubeconfig(kubeconfig, server, ca, key=None, certificate=None,
|
||||
|
||||
def get_dns_ip():
|
||||
'''Get an IP address for the DNS server on the provided cidr.'''
|
||||
# Remove the range from the cidr.
|
||||
ip = service_cidr().split('/')[0]
|
||||
# Take the last octet off the IP address and replace it with 10.
|
||||
return '.'.join(ip.split('.')[0:-1]) + '.10'
|
||||
interface = ipaddress.IPv4Interface(service_cidr())
|
||||
# Add .10 at the end of the network
|
||||
ip = interface.network.network_address + 10
|
||||
return ip.exploded
|
||||
|
||||
|
||||
def get_kubernetes_service_ip():
|
||||
'''Get the IP address for the kubernetes service based on the cidr.'''
|
||||
# Remove the range from the cidr.
|
||||
ip = service_cidr().split('/')[0]
|
||||
# Remove the last octet and replace it with 1.
|
||||
return '.'.join(ip.split('.')[0:-1]) + '.1'
|
||||
interface = ipaddress.IPv4Interface(service_cidr())
|
||||
# Add .1 at the end of the network
|
||||
ip = interface.network.network_address + 1
|
||||
return ip.exploded
|
||||
|
||||
|
||||
def handle_etcd_relation(reldata):
|
||||
|
Loading…
Reference in New Issue
Block a user