Skip to content

Commit

Permalink
update version to 1.0.2, add arm64 build
Browse files Browse the repository at this point in the history
Signed-off-by: caimingxia <mingshao.cmx@alibaba-inc.com>
  • Loading branch information
MandssS committed Aug 1, 2022
1 parent 58ef8b9 commit ccadd4b
Show file tree
Hide file tree
Showing 16 changed files with 468 additions and 102 deletions.
145 changes: 60 additions & 85 deletions .idea/workspace.xml

Large diffs are not rendered by default.

45 changes: 33 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
.PHONE: build clean
export AGENT_VERSION = 1.0.0
export AGENT_VERSION = 1.0.2
export BLADE_VERSION = 1.5.0

BLADE_SRC_ROOT=$(shell pwd)

BUILD_BINARY_PATH=build/build_binary
BUILD_HELM_PATH=build/helm3/chaos_agent
BUILD_IMAGE_PATH=build/build_image
BUILD_TARGET_PKG_DIR=$(BUILD_IMAGE_PATH)
BUILD_BINARY_MUSL_PATH=build/binary_musl
BUILD_BINARY_ARM64_PATH=build/binary_arm
BUILD_IMAGE_MUSL_PATH=build/image_musl
BUILD_IMAGE_ARM64_PATH=build/image_arm


BUILD_HELM_PATH=build/helm3/chaos-agent/
BUILD_BINARY_PATH=build

VERSION_PKG=github.com/chaosblade-io/chaos-agent/version

GO_ENV=CGO_ENABLED=1
GO_MODULE=GO111MODULE=on
#GO_PROXY=GOPROXY=https://mirrors.aliyun.com/goproxy/
GO=env $(GO_ENV) $(GO_MODULE) go
#GO_X_FLAGS=-X ${VERSION_PKG}.AgentVersion=$(AGENT_VERSION) -X '${VERSION_PKG}.Env=`uname -mv`' -X '${VERSION_PKG}.BuildTime=`date`'
GO_FLAGS=-ldflags="-s -w"
Expand All @@ -23,21 +28,37 @@ endif

build: build_binary

build_darwin: pre_build build_binary build_image
build_darwin: pre_build build_binary build_image build_chart

build_binary: cmd/chaos_agent.go
$(GO) build $(GO_FLAGS) -o $(BUILD_TARGET_PKG_DIR)/agent $<
$(GO) build $(GO_FLAGS) -o $(BUILD_BINARY_PATH)/agent $<

build_linux:
docker build -f $(BUILD_BINARY_PATH)/Dockerfile -t agent-build-musl:latest $(BUILD_BINARY_PATH)
docker build -f $(BUILD_BINARY_MUSL_PATH)/Dockerfile -t agent-build-musl:latest $(BUILD_BINARY_MUSL_PATH)
docker run --rm \
-v $(shell echo -n ${GOPATH}):/go \
-w /chaos-agent \
-v $(BLADE_SRC_ROOT):/chaos-agent \
agent-build-musl:latest
build_arm64:
docker build -f $(BUILD_BINARY_ARM64_PATH)/Dockerfile -t agent-build-arm:latest $(BUILD_BINARY_ARM64_PATH)
docker run --rm \
-v $(shell echo -n ${GOPATH}):/go \
-w /chaos-agent \
-v $(BLADE_SRC_ROOT):/chaos-agent \
agent-build-arm:latest

build_image:
build_chart:
helm package $(BUILD_HELM_PATH)
cd $(BUILD_IMAGE_PATH)
docker build --pull --build-arg BLADE_VERSION=${BLADE_VERSION} -f $(BUILD_IMAGE_PATH)/Dockerfile \
-t chaos-agent:$(AGENT_VERSION) $(BLADE_SRC_ROOT)/$(BUILD_IMAGE_PATH)

build_image:
rm -rf $(BUILD_IMAGE_MUSL_PATH)/agent
cp $(BUILD_BINARY_PATH)/agent $(BUILD_IMAGE_MUSL_PATH)
docker build --pull --build-arg BLADE_VERSION=${BLADE_VERSION} -f $(BUILD_IMAGE_MUSL_PATH)/Dockerfile \
-t chaosbladeio/chaosblade-agent:$(AGENT_VERSION) $(BLADE_SRC_ROOT)/$(BUILD_IMAGE_MUSL_PATH)

build_image_arm:
rm -rf $(BUILD_IMAGE_ARM64_PATH)/agent
cp $(BUILD_BINARY_PATH)/agent $(BUILD_IMAGE_ARM64_PATH)
docker build --pull --build-arg BLADE_VERSION=${BLADE_VERSION} -f $(BUILD_IMAGE_ARM64_PATH)/Dockerfile \
-t chaosbladeio/chaosblade-agent-arm64:$(AGENT_VERSION) $(BLADE_SRC_ROOT)/$(BUILD_IMAGE_ARM64_PATH)
28 changes: 28 additions & 0 deletions build/binary_arm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM multiarch/ubuntu-debootstrap:arm64-bionic
LABEL maintainer="Mingxia Cai"

# install gcc make git
RUN apt-get update \
&& apt-get install -y build-essential git

# The image is used to build chaosblade for musl
RUN wget http://www.musl-libc.org/releases/musl-1.1.21.tar.gz \
&& tar -zxvf musl-1.1.21.tar.gz \
&& rm musl-1.1.21.tar.gz \
&& cd musl* \
&& ./configure \
&& make \
&& make install \
&& rm -rf musl*

# install go
RUN wget https://dl.google.com/go/go1.13.10.linux-arm64.tar.gz \
&& tar -C /usr/local -xzf go1.13.10.linux-arm64.tar.gz \
&& rm -rf go1.13.10.linux-arm64.tar.gz

ENV CC /usr/local/musl/bin/musl-gcc
ENV GOOS linux
ENV PATH /usr/local/go/bin:$PATH


ENTRYPOINT [ "make" ]
File renamed without changes.
21 changes: 21 additions & 0 deletions build/helm3/chaos-agent-arm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
6 changes: 6 additions & 0 deletions build/helm3/chaos-agent-arm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
appVersion: "1.0.2"
description: A SaaS-based service that aims to improve the high availability of your applications.
name: chaosblade-box-agent
version: 1.0.2
home: https://www.alibabacloud.com/products/chaos
2 changes: 2 additions & 0 deletions build/helm3/chaos-agent-arm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Thank you for using the {{ .Release.Name }} service, you can check the service installation status by the following command:
kubectl get pods -n {{ .Release.Namespace }}.
1 change: 1 addition & 0 deletions build/helm3/chaos-agent-arm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{/* vim: set filetype=mustache: */}}
121 changes: 121 additions & 0 deletions build/helm3/chaos-agent-arm/templates/ahas_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: chaos-agent
labels:
name: chaos-agent
app: chaos-agent
spec:
selector:
matchLabels:
name: chaos-agent
template:
metadata:
labels:
name: chaos-agent
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: type
operator: NotIn
values:
- virtual-kubelet
containers:
- name: chaos-agent
image: {{ .Values.images.chaos.repository }}:{{ .Values.images.chaos.version }}
imagePullPolicy: {{ .Values.images.chaos.pullPolicy }}
env:
- name: KUBERNETES_NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DOCKER_API_VERSION
value: "1.14.0"
args:
{{- if .Values.license }}
- '--license={{ .Values.license }}'
{{- end }}
{{- if .Values.env.mode }}
- '--agent.mode={{ .Values.env.mode }}'
{{- end }}
{{- if .Values.env.name }}
- '--namespace={{ .Values.env.name }}'
{{- end }}
{{- if .Values.env.debug }}
- '--debug'
{{- end }}
{{- if .Values.controller.cluster_id }}
- '--kubernetes.cluster.id={{ .Values.controller.cluster_id }}'
{{- end }}
{{- if .Values.controller.cluster_name }}
- '--kubernetes.cluster.name={{ .Values.controller.cluster_name }}'
{{- end }}
{{- if .Values.controller.cluster_type }}
- '--kubernetes.cluster.type={{ .Values.controller.cluster_type }}'
{{- end }}
{{- if .Values.transport.endpoint }}
- '--transport.endpoint={{ .Values.transport.endpoint }}'
{{ end }}
- '--kubernetes.pod.report=true'
- '--kubernetes.externalIp.enable={{ .Values.controller.externalIp_enable }}'
securityContext:
privileged: true
resources:
requests:
cpu: 0.05
memory: 200Mi
limits:
cpu: 0.2
memory: 300Mi
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-socket
- mountPath: /etc/hosts
name: hosts
- mountPath: /run/containerd
name: containerd
- mountPath: /var/lib/containerd
name: containerd-lib
- mountPath: /etc/containerd
name: containerd-etc

dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
hostPID: true
tolerations:
- effect: NoSchedule
operator: Exists
volumes:
- hostPath:
path: /var/run/docker.sock
name: docker-socket
- hostPath:
path: /etc/hosts
name: hosts
- hostPath:
path: /run/containerd
name: containerd
- hostPath:
path: /var/lib/containerd
name: containerd-lib
- hostPath:
path: /etc/containerd
name: containerd-etc
serviceAccountName: chaos-agent

---
kind: Service
apiVersion: v1
metadata:
name: chaos-agent
spec:
type: LoadBalancer
ports:
- name: http
port: {{ .Values.transport.port }}
targetPort: {{ .Values.transport.port }}
selector:
name: chaos-agent
134 changes: 134 additions & 0 deletions build/helm3/chaos-agent-arm/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
name: chaos-agent

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
name: chaos-agent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-agent
subjects:
- kind: ServiceAccount
name: chaos-agent
namespace: {{ .Release.Namespace }}

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: chaos-agent
rules:
- apiGroups:
- ''
resources:
- pods
- pods/exec
- services
- endpoints
- configmaps
- secrets
- nodes
- namespaces
- persistentvolumes
- persistentvolumeclaims
- events
- serviceaccounts
- chaosexperiments
- chaosengines
verbs:
- "*"
- apiGroups:
- apps
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
verbs:
- "*"
- apiGroups:
- batch
resources:
- cronjobs
- jobs
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
- ingresses
verbs:
- "*"
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- chaosblade.io
resources:
- chaosblades
- chaosblades/status
verbs:
- "*"
- apiGroups:
- litmuschaos.io
resources:
- chaosexperiments
- chaosengines
- chaosresults
verbs:
- "*"
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- "*"
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
verbs:
- "*"
- nonResourceURLs:
- /api
- /api/*
- /apis
- /apis/*
- /healthz
- /openapi
- /openapi/*
- /version
- /version/
verbs:
- post
- delete
- get
Loading

0 comments on commit ccadd4b

Please sign in to comment.