Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1463 from mumoshu/amazon-vpc-cni-k8s
Browse files Browse the repository at this point in the history
feat: initial support for amazon-vpc-cni-k8s
  • Loading branch information
mumoshu authored Oct 1, 2018
2 parents c113c7e + 5dad6f8 commit 6126a93
Show file tree
Hide file tree
Showing 2,253 changed files with 984,006 additions and 401,443 deletions.
108 changes: 101 additions & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ ignored = ["github.com/kubernetes-incubator/kube-aws/hack*"]
[[constraint]]
branch = "master"
name = "github.com/mgutz/ansi"

[[constraint]]
version = "v1.2.0"
name = "github.com/aws/amazon-vpc-cni-k8s"
58 changes: 58 additions & 0 deletions core/controlplane/config/amazon_vpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package config

import (
"fmt"
"github.com/aws/amazon-vpc-cni-k8s/pkg/awsutils"
"github.com/kubernetes-incubator/kube-aws/node"
)

type AmazonVPC struct {
Enabled bool `yaml:"enabled"`
}

func (a AmazonVPC) MaxPodsScript() node.UploadedFileContent {
script := `#!/usr/bin/env bash
set -e
declare -A instance_eni_available
`

for it, num := range awsutils.InstanceENIsAvailable {
script = script + fmt.Sprintf(`instance_eni_available["%s"]=%d
`, it, num)
}

script = script + `
declare -A instance_ip_available
`
for it, num := range awsutils.InstanceIPsAvailable {
script = script + fmt.Sprintf(`instance_ip_available["%s"]=%d
`, it, num)
}

script = script + `
instance_type=$(curl http://169.254.169.254/latest/meta-data/instance-type)
enis=${instance_eni_available["$instance_type"]}
if [ "" == "$enis" ]; then
echo "unsupported instance type: no enis_per_eni defined: $instance_type" 1>&2
exit 1
fi
# According to https://github.com/aws/amazon-vpc-cni-k8s#eni-allocation
ips_per_eni=${instance_ip_available["$instance_type"]}
if [ "" == "$ips_per_eni" ]; then
echo "unsupported instance type: no ips_per_eni defined: $instance_type" 1>&2
exit 1
fi
max_pods=$(( (enis * (ips_per_eni - 1)) + 2 ))
printf $max_pods
`
return node.NewUploadedFileContent([]byte(script))
}
6 changes: 5 additions & 1 deletion core/controlplane/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func NewDefaultCluster() *Cluster {
},
KIAMSupport: KIAMSupport{
Enabled: false,
Image: model.Image{Repo: "quay.io/uswitch/kiam", Tag: "v2.7", RktPullDocker: false},
Image: model.Image{Repo: "quay.io/uswitch/kiam", Tag: "v2.8", RktPullDocker: false},
SessionDuration: "15m",
ServerAddresses: KIAMServerAddresses{ServerAddress: "localhost:443", AgentAddress: "kiam-server:443"},
},
Expand Down Expand Up @@ -218,6 +218,9 @@ func NewDefaultCluster() *Cluster {
Enabled: false,
},
Networking: Networking{
AmazonVPC: AmazonVPC{
Enabled: false,
},
SelfHosting: SelfHosting{
Type: "canal",
Typha: false,
Expand Down Expand Up @@ -787,6 +790,7 @@ type ResourceQuota struct {
}

type Networking struct {
AmazonVPC AmazonVPC `yaml:"amazonVPC"`
SelfHosting SelfHosting `yaml:"selfHosting"`
}

Expand Down
Loading

0 comments on commit 6126a93

Please sign in to comment.