Skip to content

Commit

Permalink
kubeapi sample
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <[email protected]>
  • Loading branch information
deitch committed Feb 16, 2024
1 parent 8f77232 commit f5486c0
Show file tree
Hide file tree
Showing 2,418 changed files with 727,589 additions and 310 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -937,13 +937,16 @@ endif
$(QUIET)$(PARSE_PKGS) $< > $@
$(QUIET): $@: Succeeded

# If DEV=y and file pkg/my_package/build-dev.yml returns the path to that file.
# If RSTATS=y and file pkg/my_package/build-rstats.yml returns the path to that file.
# If DEV=y and file pkg/my_package/build-dev.yml exists, returns the path to that file.
# If RSTATS=y and file pkg/my_package/build-rstats.yml exists, returns the path to that file.
# If HV=kubevirt and file pkg/my_package/build-kubevirt.yml exists, returns the path to that file.
# Ortherwise returns pkg/my_package/build.yml.
get_pkg_build_yml = $(if $(filter y,$(RSTATS)), $(call get_pkg_build_rstats_yml,$1), $(call get_pkg_build_def_yml,$1))
get_pkg_build_def_yml = $(if $(filter y,$(DEV)),$(call get_pkg_build_dev_yml,$1),build.yml)
get_pkg_build_yml = $(if $(filter kubevirt,$(HV)), $(call get_pkg_build_kubevirt_yml,$1), \
$(if $(filter y,$(RSTATS)), $(call get_pkg_build_rstats_yml,$1), \
$(if $(filter y,$(DEV)), $(call get_pkg_build_dev_yml,$1), build.yml)))
get_pkg_build_dev_yml = $(if $(wildcard pkg/$1/build-dev.yml),build-dev.yml,build.yml)
get_pkg_build_rstats_yml = $(if $(wildcard pkg/$1/build-rstats.yml),build-rstats.yml,build.yml)
get_pkg_build_kubevirt_yml = $(if $(wildcard pkg/$1/build-kubevirt.yml),build-kubevirt.yml,build.yml)

eve-%: pkg/%/Dockerfile build-tools $(RESCAN_DEPS)
$(QUIET): "$@: Begin: LINUXKIT_PKG_TARGET=$(LINUXKIT_PKG_TARGET)"
Expand Down
7 changes: 5 additions & 2 deletions pkg/pillar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ FROM target-${TARGETARCH}-build-${BUILDARCH} AS build
ARG DEV=n
ARG TARGETARCH

# some parts of pillar are build conditionally based on the hypervisor
ARG HV

# building with runtime stats
ARG RSTATS=n
ARG RSTATS_ENDPOINT=
Expand All @@ -90,10 +93,10 @@ ENV CC=${CROSS_COMPILE_ENV}gcc
ARG GOPKGVERSION

# hadolint ignore=DL4006
RUN --mount=type=cache,target=/root/.cache/go-build echo "Running go vet" && go vet ./... && \
RUN --mount=type=cache,target=/root/.cache/go-build echo "Running go vet" && make HV="$HV" vet && \
echo "Running go fmt" && ERR="$(find . -name \*.go | grep -v /vendor/ | xargs gofmt -d -e -l -s)" && \
if [ -n "$ERR" ] ; then printf 'go fmt Failed - ERR: %s' "$ERR" ; exit 1 ; fi && \
make ZARCH=${TARGETARCH} DEV="$DEV" RSTATS=$RSTATS RSTATS_ENDPOINT=$RSTATS_ENDPOINT RSTATS_TAG=$RSTATS_TAG DISTDIR=/final/opt/zededa/bin BUILD_VERSION=${GOPKGVERSION} build
make ZARCH=${TARGETARCH} HV="$HV" DEV="$DEV" RSTATS=$RSTATS RSTATS_ENDPOINT=$RSTATS_ENDPOINT RSTATS_TAG=$RSTATS_TAG DISTDIR=/final/opt/zededa/bin BUILD_VERSION=${GOPKGVERSION} build

WORKDIR /

Expand Down
10 changes: 8 additions & 2 deletions pkg/pillar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ build: $(APPS) $(APPS1)

TAGS=
ifeq ($(RSTATS),y)
TAGS:=-tags rstats
TAGS+=rstats
endif
ifneq ($(HV),)
TAGS+=$(HV)
endif
ifneq ($(TAGS),)
TAGS:=-tags "$(TAGS)"
endif

LDFLAGS=-X=main.Version=$(BUILD_VERSION)
Expand Down Expand Up @@ -90,4 +96,4 @@ fmt-check-details:
@gofmt -d $(GOFILES)

vet:
go vet ./...
go vet $(TAGS) ./...
26 changes: 26 additions & 0 deletions pkg/pillar/build-kubevirt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# linuxkit build template
#
# Copyright (c) 2024 Zededa, Inc.
# SPDX-License-Identifier: Apache-2.0
org: lfedge
image: eve-pillar
config:
binds:
- /lib/modules:/lib/modules
- /dev:/dev
- /etc/resolv.conf:/etc/resolv.conf
- /run:/run
- /config:/config
- /:/hostfs
- /persist:/persist:rshared,rbind
- /usr/bin/containerd:/usr/bin/containerd
net: host
capabilities:
- all
pid: host
rootfsPropagation: shared
devices:
- path: all
type: a
buildArgs:
- HV=kubevirt
9 changes: 9 additions & 0 deletions pkg/pillar/diskmetrics/diskmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ func GetImgInfo(log *base.LogObject, diskfile string) (*types.ImgInfo, error) {
return &imgInfo, nil
}

// GetDiskActualSize - returns ActualSize of the image
func GetDiskActualSize(log *base.LogObject, diskfile string) (uint64, error) {
imgInfo, err := GetImgInfo(log, diskfile)
if err != nil {
return 0, err
}
return imgInfo.ActualSize, nil
}

// GetDiskVirtualSize - returns VirtualSize of the image
func GetDiskVirtualSize(log *base.LogObject, diskfile string) (uint64, error) {
imgInfo, err := GetImgInfo(log, diskfile)
Expand Down
40 changes: 38 additions & 2 deletions pkg/pillar/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ require (
github.com/google/go-containerregistry v0.14.0
github.com/google/go-tpm v0.3.0
github.com/google/gopacket v1.1.19
github.com/gorilla/websocket v1.4.2
github.com/gorilla/websocket v1.5.0
github.com/grandcat/zeroconf v1.0.0
github.com/hashicorp/go-envparse v0.1.0
github.com/jackwakefield/gopac v1.0.2
github.com/jaypipes/ghw v0.8.0
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.5.0
github.com/lf-edge/edge-containers v0.0.0-20240207093504-5dfda0619b80
github.com/lf-edge/eve-api/go v0.0.0-20240115141031-10e8386433c4
github.com/lf-edge/eve-libs v0.0.0-20240207103937-2c1dfb073c07
github.com/lf-edge/go-qemu v0.0.0-20231121152149-4c467eda0c56
github.com/linuxkit/linuxkit/src/cmd/linuxkit v0.0.0-20240205114432-657b33805ef1
github.com/miekg/dns v1.1.43
github.com/moby/sys/mountinfo v0.7.1
github.com/onsi/gomega v1.24.2
github.com/onsi/gomega v1.29.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0-rc6
github.com/opencontainers/runtime-spec v1.1.0
Expand All @@ -52,6 +53,10 @@ require (
google.golang.org/grpc v1.61.0
google.golang.org/protobuf v1.32.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
kubevirt.io/api v1.1.1
)

require (
Expand Down Expand Up @@ -93,19 +98,25 @@ require (
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/docker/libtrust v0.0.0-20150526203908-9cbd2a1374f4 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/estesp/manifest-tool/v2 v2.0.7-0.20230216152337-24a86fc0b513 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-design/lockfree v0.0.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand All @@ -114,13 +125,16 @@ require (
github.com/in-toto/in-toto-golang v0.5.0 // indirect
github.com/jaypipes/pcidb v0.6.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lithammer/shortuuid/v4 v4.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mdlayher/netlink v1.7.1 // indirect
github.com/mdlayher/socket v0.4.0 // indirect
Expand All @@ -130,6 +144,9 @@ require (
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/selinux v1.11.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.1 // indirect
Expand Down Expand Up @@ -162,6 +179,7 @@ require (
golang.org/x/mod v0.15.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
Expand All @@ -170,8 +188,26 @@ require (
google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
oras.land/oras-go v1.2.5 // indirect
)

require (
github.com/imdario/mergo v0.3.13 // indirect
github.com/openshift/api v0.0.0-20230503133300-8bbcb7ca7183 // indirect
github.com/openshift/custom-resource-status v1.1.2 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
k8s.io/apiextensions-apiserver v0.26.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
kubevirt.io/containerized-data-importer-api v1.57.0-alpha1 // indirect
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit f5486c0

Please sign in to comment.