Skip to content

Commit 74e3d6c

Browse files
authored
Add /proc/cmdline parsing for tinkerbell_tls and tink_worker_image: (#115)
## Description This PR adds `/proc/cmdline` parsing for `tinkerbell_tls` and `tink_worker_image`: Boots now has the ability to not pass kernel commandline args for a registry. When not passing registry info we will need to know the location of the tink worker container image. This is handled with the `tink_worker_image` kernel commandline arg. Tink server now has the ability to run without TLS. The `tinkerbell_tls` kernel commandline arg is used to determine this. This value is parsed and passed along to the Tink worker. ## Why is this needed Fixes: # ## How Has This Been Tested? ## How are existing users impacted? What migration steps/scripts do we need? ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
2 parents 16a89f5 + ae8ea66 commit 74e3d6c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

bootkit/main.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io/ioutil"
1010
"net/http"
1111
"os"
12+
"path"
1213
"strings"
1314
"time"
1415

@@ -38,6 +39,12 @@ type tinkConfig struct {
3839

3940
// Metadata ID ... plus the other IDs :shrug:
4041
MetadataID string `json:"id"`
42+
43+
// tinkWorkerImage is the Tink worker image location.
44+
tinkWorkerImage string
45+
46+
// tinkServerTLS is whether or not to use TLS for tink-server communication.
47+
tinkServerTLS string
4148
}
4249

4350
func main() {
@@ -61,7 +68,18 @@ func main() {
6168
}
6269

6370
// Generate the path to the tink-worker
64-
imageName := fmt.Sprintf("%s/tink-worker:latest", cfg.registry)
71+
var imageName string
72+
if cfg.registry != "" {
73+
imageName = path.Join(cfg.registry, "tink-worker:latest")
74+
}
75+
if cfg.tinkWorkerImage != "" {
76+
imageName = cfg.tinkWorkerImage
77+
}
78+
if imageName == "" {
79+
// TODO(jacobweinstock): Don't panic, ever. This whole main function should ideally be a control loop that never exits.
80+
// Just keep trying all the things until they work. Similar idea to controllers in Kubernetes. Doesn't need to be that heavy though.
81+
panic("cannot pull image for tink-worker, 'docker_registry' and/or 'tink_worker_image' NOT specified in /proc/cmdline")
82+
}
6583

6684
// Generate the configuration of the container
6785
tinkContainer := &container.Config{
@@ -72,6 +90,7 @@ func main() {
7290
fmt.Sprintf("REGISTRY_PASSWORD=%s", cfg.password),
7391
fmt.Sprintf("TINKERBELL_GRPC_AUTHORITY=%s", cfg.grpcAuthority),
7492
fmt.Sprintf("TINKERBELL_CERT_URL=%s", cfg.grpcCertURL),
93+
fmt.Sprintf("TINKERBELL_TLS=%s", cfg.tinkServerTLS),
7594
fmt.Sprintf("WORKER_ID=%s", cfg.workerID),
7695
fmt.Sprintf("ID=%s", cfg.workerID),
7796
fmt.Sprintf("container_uuid=%s", cfg.MetadataID),
@@ -178,6 +197,10 @@ func parseCmdLine(cmdLines []string) (cfg tinkConfig) {
178197
// Find the worker configuration
179198
case "worker_id":
180199
cfg.workerID = cmdLine[1]
200+
case "tink_worker_image":
201+
cfg.tinkWorkerImage = cmdLine[1]
202+
case "tinkerbell_tls":
203+
cfg.tinkServerTLS = cmdLine[1]
181204
}
182205
}
183206
return cfg

0 commit comments

Comments
 (0)