mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	AWS: Allow to configure master ip and services mask
Fix script for case when neeed to setup cluster in an existen VPC and subnet with ip mask example: 10.0.0.0/8. Fixed bug to detect ip of master if provided MASTER_RESERVED_IP. For some reason detecting master ip was moved to volumes and only when MASTER_RESERVED_IP=auto. If specify IPv4 for MASTER_RESERVED_IP like `52.1.1.1`, than we could not detect ip even during last steps of setuping cluster. step the KUBE_MASTER_IP is reseted because there are no tag for the volume.
This commit is contained in:
		@@ -76,13 +76,15 @@ AWS_ASG_CMD="aws autoscaling"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
VPC_CIDR_BASE=172.20
 | 
					VPC_CIDR_BASE=172.20
 | 
				
			||||||
MASTER_IP_SUFFIX=.9
 | 
					MASTER_IP_SUFFIX=.9
 | 
				
			||||||
MASTER_INTERNAL_IP=${VPC_CIDR_BASE}.0${MASTER_IP_SUFFIX}
 | 
					 | 
				
			||||||
VPC_CIDR=${VPC_CIDR_BASE}.0.0/16
 | 
					VPC_CIDR=${VPC_CIDR_BASE}.0.0/16
 | 
				
			||||||
SUBNET_CIDR=${VPC_CIDR_BASE}.0.0/24
 | 
					SUBNET_CIDR=${VPC_CIDR_BASE}.0.0/24
 | 
				
			||||||
if [[ -n "${KUBE_SUBNET_CIDR:-}" ]]; then
 | 
					if [[ -n "${KUBE_SUBNET_CIDR:-}" ]]; then
 | 
				
			||||||
  echo "Using subnet CIDR override: ${KUBE_SUBNET_CIDR}"
 | 
					  echo "Using subnet CIDR override: ${KUBE_SUBNET_CIDR}"
 | 
				
			||||||
  SUBNET_CIDR=${KUBE_SUBNET_CIDR}
 | 
					  SUBNET_CIDR=${KUBE_SUBNET_CIDR}
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					if [[ -z "${MASTER_INTERNAL_IP-}" ]]; then
 | 
				
			||||||
 | 
					  MASTER_INTERNAL_IP="${SUBNET_CIDR%.*}${MASTER_IP_SUFFIX}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MASTER_SG_NAME="kubernetes-master-${CLUSTER_ID}"
 | 
					MASTER_SG_NAME="kubernetes-master-${CLUSTER_ID}"
 | 
				
			||||||
NODE_SG_NAME="kubernetes-minion-${CLUSTER_ID}"
 | 
					NODE_SG_NAME="kubernetes-minion-${CLUSTER_ID}"
 | 
				
			||||||
@@ -506,6 +508,7 @@ function ensure-master-ip {
 | 
				
			|||||||
    else
 | 
					    else
 | 
				
			||||||
      KUBE_MASTER_IP=`$AWS_CMD allocate-address --domain vpc --query PublicIp`
 | 
					      KUBE_MASTER_IP=`$AWS_CMD allocate-address --domain vpc --query PublicIp`
 | 
				
			||||||
      echo "Allocated Elastic IP for master: ${KUBE_MASTER_IP}"
 | 
					      echo "Allocated Elastic IP for master: ${KUBE_MASTER_IP}"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # We can't tag elastic ips.  Instead we put the tag on the persistent disk.
 | 
					    # We can't tag elastic ips.  Instead we put the tag on the persistent disk.
 | 
				
			||||||
    # It is a little weird, perhaps, but it sort of makes sense...
 | 
					    # It is a little weird, perhaps, but it sort of makes sense...
 | 
				
			||||||
@@ -513,7 +516,6 @@ function ensure-master-ip {
 | 
				
			|||||||
    # have the master IP
 | 
					    # have the master IP
 | 
				
			||||||
    add-tag ${MASTER_DISK_ID} ${TAG_KEY_MASTER_IP} ${KUBE_MASTER_IP}
 | 
					    add-tag ${MASTER_DISK_ID} ${TAG_KEY_MASTER_IP} ${KUBE_MASTER_IP}
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Creates a new DHCP option set configured correctly for Kubernetes
 | 
					# Creates a new DHCP option set configured correctly for Kubernetes
 | 
				
			||||||
@@ -790,12 +792,11 @@ function subnet-setup {
 | 
				
			|||||||
  else
 | 
					  else
 | 
				
			||||||
    EXISTING_CIDR=$($AWS_CMD describe-subnets --subnet-ids ${SUBNET_ID} --query Subnets[].CidrBlock)
 | 
					    EXISTING_CIDR=$($AWS_CMD describe-subnets --subnet-ids ${SUBNET_ID} --query Subnets[].CidrBlock)
 | 
				
			||||||
    echo "Using existing subnet with CIDR $EXISTING_CIDR"
 | 
					    echo "Using existing subnet with CIDR $EXISTING_CIDR"
 | 
				
			||||||
    VPC_CIDR=$($AWS_CMD describe-vpcs --vpc-ids ${VPC_ID} --query Vpcs[].CidrBlock)
 | 
					    if [ ! $SUBNET_CIDR = $EXISTING_CIDR ]; then
 | 
				
			||||||
    echo "VPC CIDR is $VPC_CIDR"
 | 
					      MASTER_INTERNAL_IP="${EXISTING_CIDR%.*}${MASTER_IP_SUFFIX}"
 | 
				
			||||||
    VPC_CIDR_BASE=${VPC_CIDR%.*.*}
 | 
					 | 
				
			||||||
    MASTER_INTERNAL_IP=${VPC_CIDR_BASE}.0${MASTER_IP_SUFFIX}
 | 
					 | 
				
			||||||
      echo "Assuming MASTER_INTERNAL_IP=${MASTER_INTERNAL_IP}"
 | 
					      echo "Assuming MASTER_INTERNAL_IP=${MASTER_INTERNAL_IP}"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  echo "Using subnet $SUBNET_ID"
 | 
					  echo "Using subnet $SUBNET_ID"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user