-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving to shared provisioner and splitting pause container image logic
- Loading branch information
Showing
9 changed files
with
104 additions
and
32 deletions.
There are no files selected for viewing
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,49 @@ | ||
package runtime | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
awsimds "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" | ||
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/aws/ecr" | ||
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/aws/imds" | ||
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/cli" | ||
"github.com/integrii/flaggy" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type ecrUriCmd struct { | ||
cmd *flaggy.Subcommand | ||
region string | ||
} | ||
|
||
func NewEcrUriCommand() cli.Command { | ||
c := ecrUriCmd{ | ||
cmd: flaggy.NewSubcommand("ecr-uri"), | ||
} | ||
c.cmd.Description = "Verify configuration" | ||
c.cmd.String(&c.region, "r", "region", "the region to check the ECR URI for") | ||
return &c | ||
} | ||
|
||
func (c *ecrUriCmd) Flaggy() *flaggy.Subcommand { | ||
return c.cmd | ||
} | ||
|
||
func (c *ecrUriCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error { | ||
if c.region == "" { | ||
regionResponse, err := imds.Client.GetRegion(context.Background(), &awsimds.GetRegionInput{}) | ||
if err != nil { | ||
return err | ||
} | ||
c.region = regionResponse.Region | ||
fmt.Fprintf(os.Stderr, "detected region using IMDS: %s", c.region) | ||
} | ||
registry, err := ecr.GetEKSRegistry(c.region) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(registry) | ||
return nil | ||
} |
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,11 @@ | ||
package runtime | ||
|
||
import ( | ||
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/cli" | ||
) | ||
|
||
func NewRuntimeCommand() cli.Command { | ||
container := cli.NewCommandContainer("runtime", "Runtime configuration utilities") | ||
container.AddCommand(NewEcrUriCommand()) | ||
return container.AsCommand() | ||
} |
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
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
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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
LOCAL_REF=${LOCAL_REF:-"localhost/kubernetes/pause:0.1.0"} | ||
PAUSE_CONTAINER=${PAUSE_CONTAINER:-$(eval "${PAUSE_CONTAINER_CMD}")} | ||
|
||
sudo systemctl start containerd | ||
|
||
sudo ctr --namespace k8s.io content fetch ${PAUSE_CONTAINER} --user AWS:$(aws ecr get-login-password) | ||
sudo ctr --namespace k8s.io image tag ${PAUSE_CONTAINER} ${LOCAL_REF} | ||
# store the archive locally just in case so that it can be imported in the future. | ||
sudo ctr --namespace k8s.io image export /etc/eks/pause.tar ${LOCAL_REF} | ||
# labels the image using a CRI aware key. might not be necessary | ||
sudo ctr --namespace=k8s.io image label ${LOCAL_REF} io.cri-containerd.pinned=pinned |