Skip to content

Commit

Permalink
Merge branch 'kosmos-io:main' into remove_unsed_file
Browse files Browse the repository at this point in the history
  • Loading branch information
duanmengkk authored Jan 29, 2024
2 parents 9ce56c4 + b592590 commit fd5e284
Show file tree
Hide file tree
Showing 34 changed files with 2,266 additions and 93 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/dev_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Dev Images
on:
push:
pull_request:
workflow_dispatch:
jobs:
images:
runs-on: ubuntu-latest
permissions: write-all
# not trigger on 'kosmos-io/kosmos'
if: github.repository != 'kosmos-io/kosmos'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up qemu
uses: docker/setup-qemu-action@v2
- name: Login registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 1.0.0
- name: Push images
env:
ON_PLUGINS: true
REGISTRY: ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}
TAG: ${{ steps.previoustag.outputs.tag }}
run: |
make upload-images REGISTRY=${REGISTRY%?} VERSION=$TAG
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ REGISTRY_PASSWORD?=""
REGISTRY_SERVER_ADDRESS?=""
KIND_IMAGE_TAG?="v1.25.3"

MACOS_TARGETS := clusterlink-controller-manager \
kosmos-operator \
clusterlink-elector \
clusterlink-network-manager \
clusterlink-proxy \
clustertree-cluster-manager \
scheduler \

# clusterlink-agent and clusterlink-floater only support linux platform
TARGETS := clusterlink-controller-manager \
kosmos-operator \
clusterlink-agent \
Expand All @@ -19,6 +28,11 @@ TARGETS := clusterlink-controller-manager \
clustertree-cluster-manager \
scheduler \

# If GOOS is macOS, assign the value of MACOS_TARGETS to TARGETS
ifeq ($(GOOS), darwin)
TARGETS := $(MACOS_TARGETS)
endif

CTL_TARGETS := kosmosctl

# Build code.
Expand Down Expand Up @@ -82,12 +96,13 @@ multi-platform-images: $(MP_TARGET)

.PHONY: clean
clean:
rm -rf _tmp _output
hack/clean.sh

.PHONY: update
update:
hack/update-all.sh

# verify-all.sh for verify crds vendor codegen
.PHONY: verify
verify:
hack/verify-all.sh
Expand Down Expand Up @@ -118,7 +133,7 @@ release:
@make release-kosmosctl GOOS=darwin GOARCH=arm64

release-kosmosctl:
hack/release.sh kosmosctl ${GOOS} ${GOARCH}
hack/release.sh kosmosctl ${GOOS} ${GOARCH} ${VERSION}

.PHONY: lint
lint: golangci-lint
Expand Down
1 change: 0 additions & 1 deletion deploy/clusterlink-elector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ spec:
- mountPath: /etc/clusterlink
name: proxy-config
readOnly: true
serviceAccount: clusterlink-elector
serviceAccountName: clusterlink-elector
tolerations:
- effect: NoSchedule
Expand Down
1,374 changes: 1,374 additions & 0 deletions deploy/crds/kosmos.io_clusterpodconvertpolicies.yaml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions deploy/crds/kosmos.io_podconvertpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ spec:
plural: podconvertpolicies
shortNames:
- pc
- pcs
singular: podconvertpolicy
scope: Namespaced
versions:
Expand All @@ -35,7 +34,7 @@ spec:
metadata:
type: object
spec:
description: Spec is the specification for the behaviour of the podConversion.
description: Spec is the specification for the behaviour of the PodConvertPolicy.
properties:
converters:
description: Converters are some converter for convert pod when pod
Expand Down
1 change: 0 additions & 1 deletion deploy/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ spec:
restartPolicy: Always
dnsPolicy: ClusterFirst
serviceAccountName: kosmos-scheduler
serviceAccount: kosmos-scheduler

---
apiVersion: v1
Expand Down
3 changes: 2 additions & 1 deletion hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o pipefail
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${REPO_ROOT}/hack/util.sh"

LDFLAGS="$(util::version_ldflags) ${LDFLAGS:-}"
LDFLAGS="$(util::version_ldflags "${VERSION:-}") ${LDFLAGS:-}"

function build_binary() {
local -r target=$1
Expand All @@ -39,6 +39,7 @@ function build_binary() {
done
}


function build_binary_for_platform() {
local -r target=$1
local -r platform=$2
Expand Down
26 changes: 26 additions & 0 deletions hack/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

# This script clean builds tmp files and go cache.
#
# Usage:
# hack/clean.sh
# Environments:
# BUILD_PLATFORMS: platforms to build. You can set one or more platforms separated by comma.
# e.g.: linux/amd64,linux/arm64
# Examples:
# hack/clean.sh

REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${REPO_ROOT}/hack/util.sh"

function clean() {
echo "${REPO_ROOT}"/_tmp "${REPO_ROOT}"/_output
rm -rf "${REPO_ROOT}"/_tmp "${REPO_ROOT}"/_output
util::go_clean_cache
}

clean
5 changes: 3 additions & 2 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ set -o pipefail
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${REPO_ROOT}/hack/util.sh"

LDFLAGS="$(util::version_ldflags) ${LDFLAGS:-}"
LDFLAGS="$(util::version_ldflags "$VERSION") ${LDFLAGS:-}"

function release_binary() {
local -r target=$1
local -r os=$2
local -r arch=$3
local -r tag=$4

release_binary_for_platform "${target}" "${os}" "${arch}"
release_binary_for_platform "${target}" "${os}" "${arch}" "${tag}"
}

function release_binary_for_platform() {
Expand Down
19 changes: 17 additions & 2 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,13 @@ function util::get_version() {
}

function util::version_ldflags() {
# Git information
GIT_VERSION=$(util::get_version)
# set GIT_VERSION from param
GIT_VERSION=${1:-}
# If GIT_VERSION is not provided, use util::get_version
if [ -z "$GIT_VERSION" ]; then
GIT_VERSION=$(util::get_version)
fi
#GIT_VERSION=$(util::get_version)
GIT_COMMIT_HASH=$(git rev-parse HEAD)
if git_status=$(git status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
GIT_TREESTATE="clean"
Expand Down Expand Up @@ -527,4 +532,14 @@ function util::wait_for_crd() {

echo "The following CRDs were not stored within the specified timeout of ${timeout}s: ${crd_names[*]}"
return 1
}

function util::go_clean_cache() {
set -x

# clean go cache avoid macos make error
# vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go:18:2: open /usr/local/go/src/expvar: too many open files in system
go clean -cache

set +x
}
19 changes: 19 additions & 0 deletions hack/verify-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

# Show progress
set -x

# Orders are determined by two factors:
# (1) Less Execution time item should be executed first.
# (2) More likely to fail item should be executed first.
bash "$REPO_ROOT/hack/verify-vendor.sh"
bash "$REPO_ROOT/hack/verify-crds.sh"
bash "$REPO_ROOT/hack/verify-codegen.sh"

set +x
46 changes: 46 additions & 0 deletions pkg/apis/kosmos/v1alpha1/clusterpodconvertpolicy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:nonNamespaced
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=pc
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ClusterPodConvertPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec is the specification for the behaviour of the PodConvertPolicy.
// +required
Spec ClusterPodConvertPolicySpec `json:"spec"`
}

type ClusterPodConvertPolicySpec struct {
// A label query over a set of resources.
// If name is not empty, labelSelector will be ignored.
// +required
LabelSelector metav1.LabelSelector `json:"labelSelector"`

// A label query over a set of resources.
// If name is not empty, LeafNodeSelector will be ignored.
// +option
LeafNodeSelector *metav1.LabelSelector `json:"leafNodeSelector,omitempty"`

// Converters are some converter for convert pod when pod synced from root cluster to leaf cluster
// pod will use these converters to scheduled in leaf cluster
// +optional
Converters *Converters `json:"converters,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ClusterPodConvertPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []ClusterPodConvertPolicy `json:"items"`
}
4 changes: 2 additions & 2 deletions pkg/apis/kosmos/v1alpha1/podconvertpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (

// +genclient
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=pc;pcs
// +kubebuilder:resource:shortName=pc
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type PodConvertPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec is the specification for the behaviour of the podConversion.
// Spec is the specification for the behaviour of the PodConvertPolicy.
// +required
Spec PodConvertPolicySpec `json:"spec"`
}
Expand Down
87 changes: 87 additions & 0 deletions pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fd5e284

Please sign in to comment.