Skip to content

Github action for releasing new versions #85

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

Merged
merged 1 commit into from
Feb 24, 2023
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
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: release

on:
push:
tags:
- "v*.*.*"

env:
TAG: ${{ github.ref_name }}
REGISTRY: ghcr.io

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: setupGo
uses: actions/setup-go@v3
with:
go-version: '=1.19.4'
- name: Docker login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
run: make docker-build-all TAG=${{ env.TAG }}
- name: Push docker image
run: make docker-push-all TAG=${{ env.TAG }} PROD_REGISTRY=${{ env.REGISTRY }}
release:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: setupGo
uses: actions/setup-go@v3
with:
go-version: '=1.19.4'
- name: Update manifests
run: |
make release RELEASE_TAG=${{ env.TAG }}
- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: false
draft: true
fail_on_unmatched_files: true
generate_release_notes: true
discussion_category_name: Announcements
name: ${{ env.TAG }}
files: |
out/metadata.yaml
out/bootstrap-components.yaml
out/control-plane-components.yaml
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ manifest-modification: # Set the manifest images to the staging/production bucke
release-manifests: $(RELEASE_DIR) $(KUSTOMIZE) ## Build the manifests to publish with a release
# Build bootstrap-components.
$(KUSTOMIZE) build bootstrap/config/default > $(RELEASE_DIR)/bootstrap-components.yaml
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLPLANE_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(RELEASE_DIR)/bootstrap-components.yaml"
# Build control-plane-components.
$(KUSTOMIZE) build controlplane/config/default > $(RELEASE_DIR)/control-plane-components.yaml
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLPLANE_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(RELEASE_DIR)/control-plane-components.yaml"

# Add metadata to the release artifacts
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
Expand Down Expand Up @@ -433,7 +435,7 @@ docker-push-manifest-rke2-control-plane: ## Push the multiarch manifest for the
docker manifest create --amend $(CONTROLPLANE_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLPLANE_IMG)\-&:$(TAG)~g")
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLPLANE_IMG}:${TAG} ${CONTROLPLANE_IMG}-$${arch}:${TAG}; done
docker manifest push --purge $(CONTROLPLANE_IMG):$(TAG)
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLPLANE_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/config/default/manager_image_patch.yaml"
## $(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLPLANE_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/config/default/manager_pull_policy.yaml"

.PHONY: set-manifest-pull-policy
Expand Down
21 changes: 18 additions & 3 deletions bootstrap/internal/controllers/rke2config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,

files = append(files, manifestFiles...)

var ntpServers []string
if scope.Config.Spec.AgentConfig.NTP != nil {
ntpServers = scope.Config.Spec.AgentConfig.NTP.Servers
}

cpinput := &cloudinit.ControlPlaneInput{
BaseUserData: cloudinit.BaseUserData{
AirGapped: scope.Config.Spec.AgentConfig.AirGapped,
Expand All @@ -351,7 +356,7 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
ConfigFile: initConfigFile,
RKE2Version: scope.Config.Spec.AgentConfig.Version,
WriteFiles: files,
NTPServers: scope.Config.Spec.AgentConfig.NTP.Servers,
NTPServers: ntpServers,
},
Certificates: certificates,
}
Expand Down Expand Up @@ -478,6 +483,11 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop

files = append(files, manifestFiles...)

var ntpServers []string
if scope.Config.Spec.AgentConfig.NTP != nil {
ntpServers = scope.Config.Spec.AgentConfig.NTP.Servers
}

cpinput := &cloudinit.ControlPlaneInput{
BaseUserData: cloudinit.BaseUserData{
AirGapped: scope.Config.Spec.AgentConfig.AirGapped,
Expand All @@ -486,7 +496,7 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
ConfigFile: initConfigFile,
RKE2Version: scope.Config.Spec.AgentConfig.Version,
WriteFiles: files,
NTPServers: scope.Config.Spec.AgentConfig.NTP.Servers,
NTPServers: ntpServers,
},
}

Expand Down Expand Up @@ -551,6 +561,11 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
return ctrl.Result{}, err
}

var ntpServers []string
if scope.Config.Spec.AgentConfig.NTP != nil {
ntpServers = scope.Config.Spec.AgentConfig.NTP.Servers
}

wkInput :=
&cloudinit.BaseUserData{
PreRKE2Commands: scope.Config.Spec.PreRKE2Commands,
Expand All @@ -559,7 +574,7 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
ConfigFile: wkJoinConfigFile,
RKE2Version: scope.Config.Spec.AgentConfig.Version,
WriteFiles: files,
NTPServers: scope.Config.Spec.AgentConfig.NTP.Servers,
NTPServers: ntpServers,
}

cloudInitData, err := cloudinit.NewJoinWorker(wkInput)
Expand Down
42 changes: 42 additions & 0 deletions pkg/rke2/registries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,45 @@ var _ = Describe("RKE2RegistryConfig", func() {
})
},
)

var _ = Describe("RKE2RegistryConfig is empty", func() {
var rke2ConfigReg RKE2ConfigRegistry
BeforeEach(func() {
rke2RegistryConfig := bootstrapv1.Registry{}
rke2ConfigReg = RKE2ConfigRegistry{
Registry: rke2RegistryConfig,
Client: fake.NewClientBuilder().Build(),
Ctx: context.Background(),
Logger: log.FromContext(context.Background()),
}
},
)

It("should generate a valid registries.yaml file", func() {
registryResult, files, err := GenerateRegistries(rke2ConfigReg)
Expect(err).To(Not(HaveOccurred()))
Expect(len(files)).To(Equal(0))
Expect(len(registryResult.Mirrors)).To(Equal(0))
Expect(len(registryResult.Configs)).To(Equal(0))
})
})

var _ = Describe("RKE2RegistryConfig is nil", func() {
var rke2ConfigReg RKE2ConfigRegistry
BeforeEach(func() {
rke2ConfigReg = RKE2ConfigRegistry{
Client: fake.NewClientBuilder().Build(),
Ctx: context.Background(),
Logger: log.FromContext(context.Background()),
}
},
)

It("should generate a valid registries.yaml file", func() {
registryResult, files, err := GenerateRegistries(rke2ConfigReg)
Expect(err).To(Not(HaveOccurred()))
Expect(len(files)).To(Equal(0))
Expect(len(registryResult.Mirrors)).To(Equal(0))
Expect(len(registryResult.Configs)).To(Equal(0))
})
})
1 change: 1 addition & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TokenName(clusterName string) string {
return fmt.Sprintf("%s-token", clusterName)
}

// Rke2ToKubeVersion converts an RKE2 version to a Kubernetes version
func Rke2ToKubeVersion(rk2Version string) (kubeVersion string, err error) {
var regexStr string = "v(\\d\\.\\d{2}\\.\\d)\\+rke2r\\d"
var regex *regexp.Regexp
Expand Down