Compare commits

..

3 Commits

Author SHA1 Message Date
Hussein Galal
8968fe1d62 Fix docker image tag (#52)
Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
2023-07-04 00:03:28 +03:00
Brad Davidson
84d3f768c6 Run k3s as pid 1 (#50)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2023-06-27 02:43:01 +03:00
Hussein Galal
decf24cb2a K3k chart (#51)
* Add release chart drone action

* fix release charts

* Add deploy dir to Dapper

* Add remove build step from drone k3k-chart

* Fix repo and org name

* fix ci

* add index.yaml
2023-06-24 00:27:05 +03:00
10 changed files with 141 additions and 29 deletions

View File

@@ -14,9 +14,46 @@ steps:
from_secret: github_token
commands:
- dapper ci
- echo "${DRONE_TAG}-amd64" | sed -e 's/+/-/g' >.tags
volumes:
- name: docker
path: /var/run/docker.sock
when:
branch:
exclude:
- k3k-chart
- name: package-chart
image: rancher/dapper:v0.5.0
environment:
GITHUB_TOKEN:
from_secret: github_token
commands:
- dapper package-chart
volumes:
- name: docker
path: /var/run/docker.sock
when:
branch:
- k3k-chart
instance:
- drone-publish.rancher.io
- name: release-chart
image: rancher/dapper:v0.5.0
environment:
GITHUB_TOKEN:
from_secret: github_token
commands:
- dapper release-chart
volumes:
- name: docker
path: /var/run/docker.sock
when:
branch:
- k3k-chart
instance:
- drone-publish.rancher.io
- name: github_binary_release
image: ibuildthecloud/github-release:v0.0.1
@@ -38,6 +75,9 @@ steps:
- refs/tags/*
event:
- tag
branch:
exclude:
- k3k-chart
- name: docker-publish
image: plugins/docker
@@ -56,8 +96,42 @@ steps:
- refs/tags/*
event:
- tag
branch:
exclude:
- k3k-chart
volumes:
- name: docker
host:
path: /var/run/docker.sock
path: /var/run/docker.sock
---
kind: pipeline
type: docker
name: manifest
platform:
os: linux
arch: amd64
steps:
- name: push-runtime-manifest
image: plugins/manifest
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
spec: manifest-runtime.tmpl
when:
event:
- tag
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
branch:
exclude:
- k3k-chart
depends_on:
- amd64

View File

@@ -9,10 +9,13 @@ RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0; \
fi
RUN curl -sL https://github.com/helm/chart-releaser/releases/download/v1.5.0/chart-releaser_1.5.0_linux_${ARCH}.tar.gz | tar -xz cr \
&& mv cr /bin/
ENV GO111MODULE on
ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS
ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS GITHUB_TOKEN
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3k/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_OUTPUT ./bin ./dist ./deploy
ENV DAPPER_DOCKER_SOCKET true
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}

View File

@@ -2,5 +2,5 @@ apiVersion: v2
name: k3k
description: A Helm chart for K3K
type: application
version: 0.1.1-k3k2
version: 0.1.0-r1
appVersion: 0.0.0-alpha6

2
go.mod
View File

@@ -67,7 +67,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apiserver v0.26.1
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/controller-runtime v0.14.1
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect

6
manifest-runtime.tmpl Normal file
View File

@@ -0,0 +1,6 @@
image: rancher/k3k:{{replace "+" "-" build.tag}}
manifests:
- image: rancher/k3k:{{replace "+" "-" build.tag}}-amd64
platform:
architecture: amd64
os: linux

View File

@@ -1,13 +1,12 @@
package agent
import (
"strings"
"github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1"
"github.com/rancher/k3k/pkg/controller/util"
apps "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)
func Agent(cluster *v1alpha1.Cluster) *apps.Deployment {
@@ -46,8 +45,7 @@ func Agent(cluster *v1alpha1.Cluster) *apps.Deployment {
}
func agentPodSpec(image, name string, args []string) v1.PodSpec {
privileged := true
args = append([]string{"agent", "--config", "/opt/rancher/k3s/config.yaml"}, args...)
return v1.PodSpec{
Volumes: []v1.Volume{
{
@@ -106,17 +104,12 @@ func agentPodSpec(image, name string, args []string) v1.PodSpec {
Name: name,
Image: image,
SecurityContext: &v1.SecurityContext{
Privileged: &privileged,
Privileged: pointer.BoolPtr(true),
},
Command: []string{
"/bin/sh",
},
Args: []string{
"-c",
"/bin/k3s agent --config /opt/rancher/k3s/config.yaml " +
strings.Join(args, " ") +
" && true",
"/bin/k3s",
},
Args: args,
VolumeMounts: []v1.VolumeMount{
{
Name: "config",

View File

@@ -2,13 +2,13 @@ package server
import (
"strconv"
"strings"
"github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1"
"github.com/rancher/k3k/pkg/controller/util"
apps "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)
func Server(cluster *v1alpha1.Cluster, init bool) *apps.Deployment {
@@ -58,8 +58,7 @@ func Server(cluster *v1alpha1.Cluster, init bool) *apps.Deployment {
}
func serverPodSpec(image, name string, args []string) v1.PodSpec {
privileged := true
args = append([]string{"server", "--config", "/opt/rancher/k3s/config.yaml"}, args...)
return v1.PodSpec{
Volumes: []v1.Volume{
{
@@ -118,17 +117,12 @@ func serverPodSpec(image, name string, args []string) v1.PodSpec {
Name: name,
Image: image,
SecurityContext: &v1.SecurityContext{
Privileged: &privileged,
Privileged: pointer.BoolPtr(true),
},
Command: []string{
"/bin/sh",
},
Args: []string{
"-c",
"/bin/k3s server --config /opt/rancher/k3s/config.yaml " +
strings.Join(args, " ") +
" && true",
"/bin/k3s",
},
Args: args,
VolumeMounts: []v1.VolumeMount{
{
Name: "config",

10
scripts/package-chart Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -ex
source $(dirname $0)/version
cd $(dirname $0)/..
mkdir -p deploy/
cr package --package-path deploy/ charts/k3k

32
scripts/release-chart Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
set -ex
source $(dirname $0)/version
cd $(dirname $0)/..
git fetch --tags
CHART_TAG=chart-$(grep "version: " charts/k3k/Chart.yaml | awk '{print $2}')
if [ $(git tag -l "$version") ]; then
echo "tag already exists"
exit 1
fi
# release the chart with artifacts
cr upload --token ${GITHUB_TOKEN} \
--release-name-template "chart-{{ .Version }}" \
--package-path ./deploy/ \
--git-repo k3k \
--skip-existing \
-o rancher
# update the index.yaml
cr index --token ${GITHUB_TOKEN} \
--release-name-template "chart-{{ .Version }}" \
--package-path ./deploy/ \
--index-path index.yaml \
--git-repo k3k \
-o rancher \
--push

View File

@@ -20,7 +20,7 @@ fi
SUFFIX="-${ARCH}"
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-husseingalal}
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev