Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cni): read CNI YAML outside of the dynamic provider and update to v1.5.3 #223

Merged
merged 2 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Unreleased

### Improvements

- fix(cni): read CNI YAML outside of the dynamic provider and update to v1.5.3
[#223](https://github.com/pulumi/pulumi-eks/pull/223)

## 0.18.11 (Released August 12, 2019)

### Improvements
Expand Down
14 changes: 6 additions & 8 deletions nodejs/eks/cni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ interface VpcCniInputs {
image?: string;
}

function computeVpcCniYaml(yamlPath: string, args: VpcCniInputs): string {
// Read the CNI YAML. The original source for this YAML is
// https://github.com/aws/amazon-vpc-cni-k8s/tree/master/config.
const cniYamlText = fs.readFileSync(yamlPath).toString();
function computeVpcCniYaml(cniYamlText: string, args: VpcCniInputs): string {
const cniYaml = jsyaml.safeLoadAll(cniYamlText);

// Rewrite the envvars for the CNI daemon set as per the inputs.
Expand Down Expand Up @@ -137,14 +134,14 @@ function computeVpcCniYaml(yamlPath: string, args: VpcCniInputs): string {
return cniYaml.map(o => `---\n${jsyaml.safeDump(o)}`).join("");
}

function applyVpcCniYaml(yamlPath: string, args: VpcCniInputs) {
function applyVpcCniYaml(cniYamlText: string, args: VpcCniInputs) {
// Dump the kubeconfig to a file.
const tmpKubeconfig = tmp.fileSync();
fs.writeFileSync(tmpKubeconfig.fd, args.kubeconfig);

// Compute the required CNI YAML and dump it to a file.
const tmpYaml = tmp.fileSync();
fs.writeFileSync(tmpYaml.fd, computeVpcCniYaml(yamlPath, args));
fs.writeFileSync(tmpYaml.fd, computeVpcCniYaml(cniYamlText, args));

// Call kubectl to apply the YAML.
childProcess.execSync(`kubectl apply -f ${tmpYaml.name}`, {
Expand All @@ -166,16 +163,17 @@ export class VpcCni extends pulumi.dynamic.Resource {
}

const yamlPath = path.join(__dirname, "cni", "aws-k8s-cni.yaml");
const cniYamlText = fs.readFileSync(yamlPath).toString();

const provider = {
check: (state: any, inputs: any) => Promise.resolve({inputs: inputs, failedChecks: []}),
diff: (id: pulumi.ID, state: any, inputs: any) => Promise.resolve({}),
create: (inputs: any) => {
applyVpcCniYaml(yamlPath, <VpcCniInputs>inputs);
applyVpcCniYaml(cniYamlText, <VpcCniInputs>inputs);
return Promise.resolve({id: crypto.randomBytes(8).toString("hex"), outs: {}});
},
update: (id: pulumi.ID, state: any, inputs: any) => {
applyVpcCniYaml(yamlPath, <VpcCniInputs>inputs);
applyVpcCniYaml(cniYamlText, <VpcCniInputs>inputs);
return Promise.resolve({outs: {}});
},
read: (id: pulumi.ID, state: any) => Promise.resolve({id: id, props: state}),
Expand Down
6 changes: 1 addition & 5 deletions nodejs/eks/cni/aws-k8s-cni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spec:
tolerations:
- operator: Exists
containers:
- image: 602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon-k8s-cni:v1.5.2
- image: 602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon-k8s-cni:v1.5.3
imagePullPolicy: Always
ports:
- containerPort: 61678
Expand All @@ -104,10 +104,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
metral marked this conversation as resolved.
Show resolved Hide resolved
resources:
requests:
cpu: 10m
Expand Down