Skip to content

Commit 25ebdf3

Browse files
committed
workout
1 parent 8656be9 commit 25ebdf3

File tree

17 files changed

+126
-5409
lines changed

17 files changed

+126
-5409
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
1717

1818
- name: Run golangci-lint
19-
uses: reviewdog/action-golangci-lint@v2
19+
uses: reviewdog/action-golangci-lint@f9bba13753278f6a73b27a56a3ffb1bfda90ed71 # v2
2020
with:
2121
go_version: "1.25.4"
2222
fail_level: "none"
@@ -26,10 +26,10 @@ jobs:
2626
needs: lint
2727
steps:
2828
- name: Checkout source code
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
3030

3131
- name: Setup Go
32-
uses: actions/setup-go@v3
32+
uses: actions/setup-go@be3c94b385c4f180051c996d336f57a34c397495 # v3
3333
with:
3434
go-version: '1.25.4'
3535

.github/workflows/release.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v5
27+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
2828

2929
- name: Set up Go
30-
uses: actions/setup-go@v3
30+
uses: actions/setup-go@be3c94b385c4f180051c996d336f57a34c397495 # v3
3131
with:
3232
go-version: '1.25.4'
3333

34-
- uses: anchore/sbom-action/download-syft@v0.20.6
34+
- uses: anchore/sbom-action/download-syft@f8bdd1d8ac5e901a77a92f111440fdb1b593736b # v0.20.6
3535

3636
- name: Run GoReleaser
37-
uses: goreleaser/goreleaser-action@v4
37+
uses: goreleaser/goreleaser-action@5fdedb94abba051217030cc86d4523cf3f02243d # v4
3838
with:
3939
distribution: goreleaser
4040
args: release --clean
@@ -46,7 +46,7 @@ jobs:
4646

4747
steps:
4848
- name: Checkout repository
49-
uses: actions/checkout@v5
49+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
5050

5151
# - name: Extract metadata (tags, labels) for Docker
5252
# id: meta
@@ -55,13 +55,13 @@ jobs:
5555
# images: ${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
5656

5757
- name: Set up QEMU
58-
uses: docker/setup-qemu-action@v3
58+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
5959

6060
- name: Set up Docker Buildx
61-
uses: docker/setup-buildx-action@v3
61+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
6262

6363
- name: Install cosign
64-
uses: sigstore/cosign-installer@v3
64+
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
6565

6666
- name: Log in to the GitHub Container registry
6767
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
@@ -71,14 +71,14 @@ jobs:
7171
password: ${{ secrets.GITHUB_TOKEN }}
7272

7373
- name: Login to Docker Hub
74-
uses: docker/login-action@v2
74+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2
7575
with:
7676
username: ${{ secrets.DOCKERHUB_USERNAME }}
7777
password: ${{ secrets.DOCKERHUB_TOKEN }}
7878

7979
- name: Build and push
8080
id: buildpush
81-
uses: docker/build-push-action@v6
81+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
8282
with:
8383
platforms: linux/amd64,linux/arm64
8484
sbom: true
@@ -106,13 +106,13 @@ jobs:
106106

107107
steps:
108108
- name: Checkout repository
109-
uses: actions/checkout@v5
109+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
110110

111111
- name: Set up Helm
112-
uses: azure/setup-helm@v4
112+
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4
113113

114114
- name: Setup yq
115-
uses: mikefarah/yq@v4
115+
uses: mikefarah/yq@065b200af9851db0d5132f50bc10b1406ea5c0a8 # v4
116116

117117
- name: Log in to GitHub Container Registry
118118
run: |
@@ -130,4 +130,4 @@ jobs:
130130
- name: Push Helm chart to GHCR
131131
run: |
132132
CLEAN_VERSION=$(echo "$RELEASE_VERSION" | sed 's/^v//')
133-
helm push "./netassert-${CLEAN_VERSION}.tgz" oci://ghcr.io/${{ github.repository_owner }}/charts
133+
helm push "./netassert-${CLEAN_VERSION}.tgz" oci://ghcr.io/${{ github.repository_owner }}/charts

cmd/netassert/cli/ping.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import (
66
"os"
77
"time"
88

9+
"github.com/hashicorp/go-hclog"
910
"github.com/spf13/cobra"
1011

12+
"github.com/controlplaneio/netassert/v2/internal/kubeops"
1113
"github.com/controlplaneio/netassert/v2/internal/logger"
1214
)
1315

@@ -31,21 +33,20 @@ var pingCmd = &cobra.Command{
3133
Run: func(cmd *cobra.Command, args []string) {
3234
ctx, cancel := context.WithTimeout(context.Background(), pingCmdCfg.PingTimeout)
3335
defer cancel()
34-
ping(ctx)
36+
lg := logger.NewHCLogger("info", fmt.Sprintf("%s-%s", appName, version), os.Stdout)
37+
k8sSvc, err := createService(pingCmdCfg.KubeConfig, lg)
38+
39+
if err != nil {
40+
lg.Error("Ping failed, unable to build K8s Client", "error", err)
41+
os.Exit(1)
42+
}
43+
ping(ctx, lg, k8sSvc)
3544
},
3645
Version: rootCmd.Version,
3746
}
3847

3948
// checkEphemeralContainerSupport checks to see if ephemeral containers are supported by the K8s server
40-
func ping(ctx context.Context) {
41-
lg := logger.NewHCLogger("info", fmt.Sprintf("%s-%s", appName, version), os.Stdout)
42-
43-
k8sSvc, err := createService(pingCmdCfg.KubeConfig, lg)
44-
45-
if err != nil {
46-
lg.Error("Ping failed, unable to build K8s Client", "error", err)
47-
os.Exit(1)
48-
}
49+
func ping(ctx context.Context, lg hclog.Logger, k8sSvc *kubeops.Service) {
4950

5051
if err := k8sSvc.PingHealthEndpoint(ctx, apiServerHealthEndpoint); err != nil {
5152
lg.Error("Ping failed", "error", err)

cmd/netassert/cli/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func runTests(lg hclog.Logger) error {
8282

8383
// ping the kubernetes cluster and check to see if
8484
// it is alive and that it has support for ephemeral container(s)
85-
ping(ctx)
85+
ping(ctx, lg, k8sSvc)
8686

8787
// initialise our test runner
8888
testRunner := engine.New(k8sSvc, lg)

e2e/clusters/aws-eks-terraform-module/eks.tf

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,43 @@ data "aws_availability_zones" "available" {}
88

99
module "eks" {
1010
source = "terraform-aws-modules/eks/aws"
11-
version = "~> 19.0"
12-
11+
version = "~> 20.0"
12+
#version = "~> 19"
13+
1314

1415
cluster_name = var.cluster_name
1516
cluster_version = var.cluster_version
1617

1718
vpc_id = module.vpc.vpc_id
1819
subnet_ids = module.vpc.private_subnets
1920
cluster_endpoint_public_access = true
20-
21-
eks_managed_node_group_defaults = {
22-
ami_type = "AL2_x86_64"
21+
enable_cluster_creator_admin_permissions = true
22+
23+
cluster_addons = {
24+
vpc-cni = {
25+
before_compute = true
26+
most_recent = true
27+
configuration_values = jsonencode({
28+
#resolve_conflicts_on_update = "OVERWRITE"
29+
enableNetworkPolicy = var.enable_vpc_network_policies ? "true" : "false"
30+
})
31+
}
2332
}
2433

2534
eks_managed_node_groups = {
26-
27-
one = {
35+
example = {
2836
name = "${var.node_group_name}1"
2937

38+
# Starting on 1.30, AL2023 is the default AMI type for EKS managed node groups
39+
ami_type = "AL2023_x86_64_STANDARD"
3040
instance_types = ["t3.medium"]
3141

3242
min_size = 0
3343
max_size = 3
3444
desired_size = var.desired_size
3545
}
36-
37-
two = {
38-
name = "${var.node_group_name}2"
39-
40-
instance_types = ["m5.large"]
41-
42-
min_size = 0
43-
max_size = 3
44-
desired_size = var.desired_size
45-
}
46-
4746
}
4847

49-
5048
# Extend node-to-node security group rules
5149
node_security_group_additional_rules = {
5250
ingress_self_all = {
@@ -57,10 +55,19 @@ module "eks" {
5755
type = "ingress"
5856
self = true
5957
}
58+
59+
egress_all = {
60+
description = "Node all egress"
61+
protocol = "-1"
62+
from_port = 0
63+
to_port = 0
64+
type = "egress"
65+
cidr_blocks = ["0.0.0.0/0"]
66+
ipv6_cidr_blocks = ["::/0"]
67+
}
6068
}
6169
}
6270

63-
6471
resource "null_resource" "generate_kubeconfig" {
6572
depends_on = [module.eks]
6673

e2e/clusters/aws-eks-terraform-module/variables.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ variable "kubeconfig_file" {
1919
default = ".kubeconfig"
2020
}
2121

22-
2322
variable "desired_size" {
2423
type = number
2524
description = "desired size of the worker node pool"
2625
default = 0
2726
}
2827

29-
3028
variable "node_group_name" {
3129
type = string
3230
description = "prefix of the node group"
3331
default = "group"
3432
}
33+
34+
variable "enable_vpc_network_policies" {
35+
type = bool
36+
description = "enable or disable vpc network policies"
37+
}

e2e/clusters/aws-eks-terraform-module/vpc.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module "vpc" {
33

44
// set VPC name same as the EKS cluster name
55
name = var.cluster_name
6+
version = "~> 5.0"
67

78
cidr = "10.0.0.0/16"
89
azs = slice(data.aws_availability_zones.available.names, 0, 3)
@@ -13,6 +14,7 @@ module "vpc" {
1314
enable_nat_gateway = true
1415
single_nat_gateway = true
1516
enable_dns_hostnames = true
17+
enable_dns_support = true
1618

1719
public_subnet_tags = {
1820
"kubernetes.io/cluster/${var.cluster_name}" = "shared"

0 commit comments

Comments
 (0)