Make AWS region configurable in the operator cofig map (#333)
This commit is contained in:
		
							parent
							
								
									74b19b449e
								
							
						
					
					
						commit
						7394c15d0a
					
				|  | @ -212,6 +212,9 @@ words. | ||||||
|   pods. Only used when combined with |   pods. Only used when combined with | ||||||
|   [kube2iam](https://github.com/jtblin/kube2iam) project on AWS. The default is empty. |   [kube2iam](https://github.com/jtblin/kube2iam) project on AWS. The default is empty. | ||||||
| 
 | 
 | ||||||
|  | * **aws_region** | ||||||
|  |   AWS region used to store ESB volumes. | ||||||
|  | 
 | ||||||
| ## Debugging the operator | ## Debugging the operator | ||||||
| * **debug_logging** | * **debug_logging** | ||||||
|   boolean parameter that toggles verbose debug logs from the operator. The |   boolean parameter that toggles verbose debug logs from the operator. The | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ data: | ||||||
|   # pam_role_name: zalandos |   # pam_role_name: zalandos | ||||||
|   # pam_configuration: | |   # pam_configuration: | | ||||||
|   #  https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees |   #  https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees | ||||||
|  |   aws_region: eu-central-1 | ||||||
|   db_hosted_zone: db.example.com |   db_hosted_zone: db.example.com | ||||||
|   master_dns_name_format: '{cluster}.{team}.staging.{hostedzone}' |   master_dns_name_format: '{cluster}.{team}.staging.{hostedzone}' | ||||||
|   replica_dns_name_format: '{cluster}-repl.{team}.staging.{hostedzone}' |   replica_dns_name_format: '{cluster}-repl.{team}.staging.{hostedzone}' | ||||||
|  |  | ||||||
|  | @ -447,7 +447,7 @@ func (c *Cluster) syncVolumes() error { | ||||||
| 	if !act { | 	if !act { | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| 	if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{}}); err != nil { | 	if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{AWSRegion: c.OpConfig.AWSRegion}}); err != nil { | ||||||
| 		return fmt.Errorf("could not sync volumes: %v", err) | 		return fmt.Errorf("could not sync volumes: %v", err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -76,6 +76,7 @@ type Config struct { | ||||||
| 	// value of this string must be valid JSON or YAML; see initPodServiceAccount
 | 	// value of this string must be valid JSON or YAML; see initPodServiceAccount
 | ||||||
| 	PodServiceAccountDefinition string `name:"pod_service_account_definition" default:""` | 	PodServiceAccountDefinition string `name:"pod_service_account_definition" default:""` | ||||||
| 	DbHostedZone                string `name:"db_hosted_zone" default:"db.example.com"` | 	DbHostedZone                string `name:"db_hosted_zone" default:"db.example.com"` | ||||||
|  | 	AWSRegion                   string `name:"aws_region" default:"eu-central-1"` | ||||||
| 	WALES3Bucket                string `name:"wal_s3_bucket"` | 	WALES3Bucket                string `name:"wal_s3_bucket"` | ||||||
| 	LogS3Bucket                 string `name:"log_s3_bucket"` | 	LogS3Bucket                 string `name:"log_s3_bucket"` | ||||||
| 	KubeIAMRole                 string `name:"kube_iam_role"` | 	KubeIAMRole                 string `name:"kube_iam_role"` | ||||||
|  |  | ||||||
|  | @ -4,8 +4,6 @@ import "time" | ||||||
| 
 | 
 | ||||||
| // AWS specific constants used by other modules
 | // AWS specific constants used by other modules
 | ||||||
| const ( | const ( | ||||||
| 	// default region for AWS. TODO: move it to the operator configuration
 |  | ||||||
| 	AWSRegion = "eu-central-1" |  | ||||||
| 	// EBS related constants
 | 	// EBS related constants
 | ||||||
| 	EBSVolumeIDStart = "/vol-" | 	EBSVolumeIDStart = "/vol-" | ||||||
| 	EBSProvisioner   = "kubernetes.io/aws-ebs" | 	EBSProvisioner   = "kubernetes.io/aws-ebs" | ||||||
|  |  | ||||||
|  | @ -16,11 +16,12 @@ import ( | ||||||
| // EBSVolumeResizer implements volume resizing interface for AWS EBS volumes.
 | // EBSVolumeResizer implements volume resizing interface for AWS EBS volumes.
 | ||||||
| type EBSVolumeResizer struct { | type EBSVolumeResizer struct { | ||||||
| 	connection *ec2.EC2 | 	connection *ec2.EC2 | ||||||
|  | 	AWSRegion  string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ConnectToProvider connects to AWS.
 | // ConnectToProvider connects to AWS.
 | ||||||
| func (c *EBSVolumeResizer) ConnectToProvider() error { | func (c *EBSVolumeResizer) ConnectToProvider() error { | ||||||
| 	sess, err := session.NewSession(&aws.Config{Region: aws.String(constants.AWSRegion)}) | 	sess, err := session.NewSession(&aws.Config{Region: aws.String(c.AWSRegion)}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return fmt.Errorf("could not establish AWS session: %v", err) | 		return fmt.Errorf("could not establish AWS session: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue