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

Add support for using CNI #103

Merged
merged 1 commit into from
Apr 19, 2024
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
1 change: 1 addition & 0 deletions proto/depot/cloud/v3/machine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ message RegisterMachineResponse {
// when all customers are using context logging.
optional bool enable_context_logging = 17;
optional string vector_config = 18;
optional bool enable_cni = 19;
}

// EngineTask represents an instruction to start an engine daemon
Expand Down
2 changes: 1 addition & 1 deletion src/gen/ts/depot/cloud/v3/machine_connect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-connect-es v0.13.0 with parameter "target=ts,import_extension=none"
// @generated by protoc-gen-connect-es v0.12.0 with parameter "target=ts,import_extension=none"
// @generated from file depot/cloud/v3/machine.proto (package depot.cloud.v3, syntax proto3)
/* eslint-disable */
// @ts-nocheck
Expand Down
6 changes: 6 additions & 0 deletions src/gen/ts/depot/cloud/v3/machine_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ export class RegisterMachineResponse_BuildKitTask extends Message<RegisterMachin
*/
vectorConfig?: string

/**
* @generated from field: optional bool enable_cni = 19;
*/
enableCni?: boolean

constructor(data?: PartialMessage<RegisterMachineResponse_BuildKitTask>) {
super()
proto3.util.initPartial(data, this)
Expand All @@ -525,6 +530,7 @@ export class RegisterMachineResponse_BuildKitTask extends Message<RegisterMachin
{no: 16, name: 'enable_debug_logging', kind: 'scalar', T: 8 /* ScalarType.BOOL */, opt: true},
{no: 17, name: 'enable_context_logging', kind: 'scalar', T: 8 /* ScalarType.BOOL */, opt: true},
{no: 18, name: 'vector_config', kind: 'scalar', T: 9 /* ScalarType.STRING */, opt: true},
{no: 19, name: 'enable_cni', kind: 'scalar', T: 8 /* ScalarType.BOOL */, opt: true},
])

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RegisterMachineResponse_BuildKitTask {
Expand Down
16 changes: 16 additions & 0 deletions src/tasks/buildkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ keepBytes = ${cacheSizeBytes}
`
await fsp.writeFile('/etc/buildkit/buildkitd.toml', config, {mode: 0o644})

if (task.enableCni) {
const cniConfig = {
cniVersion: '1.0.0',
name: 'buildkit',
type: 'bridge',
bridge: 'buildkit0',
isDefaultGateway: true,
forceAddress: false,
ipMasq: true,
hairpinMode: true,
ipam: {type: 'host-local', ranges: [[{subnet: '192.168.0.0/16'}]]},
}
await fsp.mkdir('/etc/buildkit', {recursive: true})
await fsp.writeFile('/etc/buildkit/cni.json', JSON.stringify(cniConfig, null, 2), {mode: 0o644})
}

const controller = new AbortController()
const signal = controller.signal

Expand Down