Skip to content

Commit

Permalink
Merge pull request #2947 from qqshfox/support_china
Browse files Browse the repository at this point in the history
support china region
  • Loading branch information
justinsb authored Jul 15, 2017
2 parents 50c130a + fc50984 commit 3538fe1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
4 changes: 2 additions & 2 deletions dns-controller/cmd/dns-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func main() {
glog.Flush()

dnsProviderId := "aws-route53"
flags.StringVar(&dnsProviderId, "dns", dnsProviderId, "DNS provider we should use (aws-route53, google-clouddns, coredns)")
flags.StringVar(&dnsProviderId, "dns", dnsProviderId, "DNS provider we should use (aws-route53, google-clouddns, coredns, gossip)")

gossipListen := "0.0.0.0:3998"
flags.StringVar(&gossipListen, "gossip-listen", gossipListen, "The address on which to listen if gossip is enabled")
Expand Down Expand Up @@ -107,7 +107,7 @@ func main() {
//}

var dnsProviders []dnsprovider.Interface
{
if dnsProviderId != "gossip" {
var file io.Reader
if dnsProviderId == k8scoredns.ProviderName {
var lines []string
Expand Down
11 changes: 10 additions & 1 deletion nodeup/pkg/bootstrap/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,16 @@ func (i *Installation) buildSystemdJob() *nodetasks.Service {
manifest.Set("Unit", "Description", "Run kops bootstrap (nodeup)")
manifest.Set("Unit", "Documentation", "https://github.com/kubernetes/kops")

var buffer bytes.Buffer

if os.Getenv("AWS_REGION") != "" {
buffer.WriteString("\"AWS_REGION=")
buffer.WriteString(os.Getenv("AWS_REGION"))
buffer.WriteString("\" ")
}

// Pass in required credentials when using user-defined s3 endpoint
if os.Getenv("S3_ENDPOINT") != "" {
var buffer bytes.Buffer
buffer.WriteString("\"S3_ENDPOINT=")
buffer.WriteString(os.Getenv("S3_ENDPOINT"))
buffer.WriteString("\" ")
Expand All @@ -125,7 +132,9 @@ func (i *Installation) buildSystemdJob() *nodetasks.Service {
buffer.WriteString("\"S3_SECRET_ACCESS_KEY=")
buffer.WriteString(os.Getenv("S3_SECRET_ACCESS_KEY"))
buffer.WriteString("\" ")
}

if buffer.String() != "" {
manifest.Set("Service", "Environment", buffer.String())
}

Expand Down
15 changes: 11 additions & 4 deletions nodeup/pkg/model/protokube.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,18 @@ func (t *ProtokubeBuilder) ProtokubeFlags(k8sVersion semver.Version) *ProtokubeF
}

func (t *ProtokubeBuilder) ProtokubeEnvironmentVariables() string {
var buffer bytes.Buffer

if os.Getenv("AWS_REGION") != "" {
buffer.WriteString(" ")
buffer.WriteString("-e 'AWS_REGION=")
buffer.WriteString(os.Getenv("AWS_REGION"))
buffer.WriteString("'")
buffer.WriteString(" ")
}

// Pass in required credentials when using user-defined s3 endpoint
if os.Getenv("S3_ENDPOINT") != "" {
var buffer bytes.Buffer
buffer.WriteString(" ")
buffer.WriteString("-e S3_ENDPOINT=")
buffer.WriteString("'")
Expand All @@ -268,9 +277,7 @@ func (t *ProtokubeBuilder) ProtokubeEnvironmentVariables() string {
buffer.WriteString(os.Getenv("S3_SECRET_ACCESS_KEY"))
buffer.WriteString("'")
buffer.WriteString(" ")

return buffer.String()
}

return ""
return buffer.String()
}
8 changes: 8 additions & 0 deletions pkg/model/bootstrapscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ func (b *BootstrapScript) ResourceNodeUp(ig *kops.InstanceGroup) (*fi.ResourceHo
}
return ""
},

"AWS_REGION": func() string {
if os.Getenv("AWS_REGION") != "" {
return fmt.Sprintf("export AWS_REGION=%s\n",
os.Getenv("AWS_REGION"))
}
return ""
},
}

templateResource, err := NewTemplateResource("nodeup", resources.AWSNodeUpTemplate, functions, nil)
Expand Down
1 change: 1 addition & 0 deletions pkg/model/resources/nodeup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ NODEUP_URL={{ NodeUpSource }}
NODEUP_HASH={{ NodeUpSourceHash }}
{{ S3Env }}
{{ AWS_REGION }}
function ensure-install-dir() {
INSTALL_DIR="/var/cache/kubernetes-install"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/minimal/cloudformation.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion upup/pkg/fi/cloudup/template_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package cloudup
import (
"encoding/base64"
"fmt"
"os"
"strings"
"text/template"

Expand Down Expand Up @@ -138,7 +139,11 @@ func (tf *TemplateFunctions) DnsControllerArgv() ([]string, error) {

switch kops.CloudProviderID(tf.cluster.Spec.CloudProvider) {
case kops.CloudProviderAWS:
argv = append(argv, "--dns=aws-route53")
if strings.HasPrefix(os.Getenv("AWS_REGION"), "cn-") {
argv = append(argv, "--dns=gossip")
} else {
argv = append(argv, "--dns=aws-route53")
}
case kops.CloudProviderGCE:
argv = append(argv, "--dns=google-clouddns")
case kops.CloudProviderVSphere:
Expand Down

0 comments on commit 3538fe1

Please sign in to comment.