This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1463 from mumoshu/amazon-vpc-cni-k8s
feat: initial support for amazon-vpc-cni-k8s
- Loading branch information
Showing
2,253 changed files
with
984,006 additions
and
401,443 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.