Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.

Release 2.4.3 rc1 #66

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ef1971
fix(proto, grpc, protoc): Add go_package in proto definition
lmvaibhavk Apr 9, 2021
2904184
feat(release2.3.0):Configured Travis build config file to take Docker…
lmshubhashri Apr 15, 2021
2c00dc9
DEV-76698- updated apiextesions to use v1 apis instead of v1beta1 apis
lmshubhashri Jul 14, 2021
27daed8
DEV-76698- Added openAPIV3 schema validations for CollectorSet resource.
lmshubhashri Jul 19, 2021
1ec8c62
DEV-76698- removed unwanted code.
lmshubhashri Jul 19, 2021
3e7c0e6
DEV-76698- rephrased descriptions as per review comments.
lmshubhashri Jul 22, 2021
a488119
DEV-76698: review comments
lmshubhashri Jul 22, 2021
31e36e9
DEV-76698-handled updating existing crd objects
lmshubhashri Jul 23, 2021
a3ebb86
DEV-76698: Added few more validations for crd schema
lmshubhashri Jul 26, 2021
4b3e651
DEV-76698: changed function name
lmshubhashri Jul 30, 2021
8f045ec
DEV-76698:Corrected string to byte array conversion.
lmshubhashri Aug 2, 2021
ee70599
Added new api for v1alpha2
lmshubhashri Aug 24, 2021
1df48e8
v1alpha2 changes.
lmshubhashri Aug 24, 2021
c7cefa9
retaining old version
lmshubhashri Aug 31, 2021
c017774
Upgrade handling
lmshubhashri Sep 2, 2021
9116599
removed commented code.
lmshubhashri Sep 2, 2021
4c96576
DEV-76698: fixed gofmt error
lmshubhashri Sep 6, 2021
0ec9803
go formatters
lmshubhashri Sep 13, 2021
1ca2474
Pull request #47: DEV-76698
lmshubhashri Sep 15, 2021
4523a83
fix(Labels and annotations): Added support for Labels and annotations…
lmshubhashri Dec 22, 2021
4948cb8
feat(add log for proxy): add logger for proxy setup in argus and csc
Jan 5, 2022
52709ae
fixed hadolint issue
sagar-mamdapure Jan 19, 2022
c19c0dc
Pull request #51: fixed hadolint issue
sagar-mamdapure Jan 19, 2022
97a3a14
fix(crd-schema): define collectorset crd schema
lmvaibhavk Feb 9, 2022
011a87f
fix(crd-schema): define collectorset crd schema
lmvaibhavk Feb 9, 2022
ad52ab3
Merge remote-tracking branch 'stash-develop/develop' into release-2.4…
lmshubhashri Feb 10, 2022
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
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
dist: trusty
sudo: required

services:
- docker

language: generic

install:
- mkdir -p $HOME/goroot
- curl -L https://storage.googleapis.com/golang/go1.14.1.linux-amd64.tar.gz | tar -xz --strip-components=1 -C $HOME/goroot
- export GOROOT=$HOME/goroot
- export GOPATH=$HOME/gopath
- export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
- mkdir -p $GOPATH/src/github.com/autonomy/conform
- rsync -az ${TRAVIS_BUILD_DIR}/ $GOPATH/src/github.com/autonomy/conform/
- export TRAVIS_BUILD_DIR=$GOPATH/src/github.com/autonomy/conform
- cd $GOPATH/src/github.com/autonomy/conform
- sudo rm -rf /etc/apt/sources.list.d
- sudo apt-get -y remove docker docker-engine
- sudo apt-get -y update
- sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y install docker-ce
- echo "$DOCKER_TOKEN" | docker login --username "$DOCKER_USERNAME" --password-stdin

script:
- make VERSION=latest

after_success:
- docker run --volume=$(pwd):/out --entrypoint=cp logicmonitor/collectorset-controller:latest /coverage.txt /out
- bash <(curl -s https://codecov.io/bash)
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.14 as api
WORKDIR /go/src/github.com/logicmonitor/k8s-collectorset-controller
RUN apt-get update
RUN apt-get -y install bsdtar
RUN apt-get -y install --no-install-recommends bsdtar
RUN go get github.com/golang/protobuf/protoc-gen-go
RUN curl -L https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip | bsdtar -xf - --strip-components=1 -C /bin bin/protoc \
&& chmod +x /bin/protoc
Expand All @@ -11,7 +11,7 @@ RUN protoc -I proto proto/api.proto \
--go_out=plugins=grpc:api --go_opt=paths=source_relative

FROM golang:1.14-alpine as codegen
RUN apk add --update git
RUN apk add --no-cache git
RUN go get github.com/kubernetes/code-generator/cmd/deepcopy-gen || true \
&& cd /go/src/github.com/kubernetes/code-generator \
&& git checkout remotes/origin/release-1.17 \
Expand Down Expand Up @@ -42,9 +42,7 @@ RUN cp coverage.txt /coverage.txt

FROM alpine:3.6
LABEL maintainer="LogicMonitor <argus@logicmonitor.com>"
RUN apk --update add ca-certificates \
&& rm -rf /var/cache/apk/* \
&& rm -rf /var/lib/apk/*
RUN apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=api /go/src/github.com/logicmonitor/k8s-collectorset-controller/api/* /tmp/
COPY --from=codegen /go/src/github.com/logicmonitor/k8s-collectorset-controller/pkg/apis/v1alpha2/zz_generated.deepcopy.go /tmp/
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

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

202 changes: 20 additions & 182 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

crv1alpha2 "github.com/logicmonitor/k8s-collectorset-controller/pkg/apis/v1alpha2"
log "github.com/sirupsen/logrus"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -21,8 +22,6 @@ import (

const crdName = crv1alpha2.CollectorSetResourcePlural + "." + crv1alpha2.GroupName

var preserveUnknownFields = true

// Client represents the CollectorSet client.
type Client struct {
Clientset *clientset.Clientset
Expand Down Expand Up @@ -68,193 +67,27 @@ func NewForConfig(cfg *rest.Config) (*Client, *runtime.Scheme, error) {
return c, s, nil
}

func getCustomResourceDefinationSchema() *apiextensionsv1.JSONSchemaProps {
minValue := 0.0
minReplicas := 1.0
minGroupID := -1.0
defaultReplicas, _ := json.Marshal(1) //nolint:gosec

return &apiextensionsv1.JSONSchemaProps{
Description: "The collectorset specefication schema",
Type: "object",
Required: []string{"spec"},
Properties: map[string]apiextensionsv1.JSONSchemaProps{
"spec": {
Type: "object",
Required: []string{"imageRepository", "imageTag", "imagePullPolicy", "replicas", "size", "clusterName"},
Properties: map[string]apiextensionsv1.JSONSchemaProps{
"imageRepository": {
Description: "The image repository of the collector container",
Type: "string",
Default: &apiextensionsv1.JSON{
Raw: []byte("\"logicmonitor/collector\""),
},
},
"imageTag": {
Description: "The image tag of the collector container",
Type: "string",
Default: &apiextensionsv1.JSON{
Raw: []byte("\"latest\""),
},
},
"imagePullPolicy": {
Description: "The image pull policy of the collector container",
Type: "string",
Default: &apiextensionsv1.JSON{
Raw: []byte("\"Always\""),
},
Enum: []apiextensionsv1.JSON{
{
Raw: []byte("\"Always\""),
},
{
Raw: []byte("\"IfNotPresent\""),
},
{
Raw: []byte("\"Never\""),
},
},
},
"replicas": {
Description: "The number of collector replicas",
Type: "integer",
Minimum: &minReplicas,
Default: &apiextensionsv1.JSON{
Raw: defaultReplicas,
},
},
"size": {
Description: "The collector size. Available collector sizes: nano, small, medium, large, extra_large, double_extra_large",
Type: "string",
Default: &apiextensionsv1.JSON{
Raw: []byte("\"nano\""),
},
Enum: []apiextensionsv1.JSON{
{
Raw: []byte("\"nano\""),
},
{
Raw: []byte("\"small\""),
},
{
Raw: []byte("\"medium\""),
},
{
Raw: []byte("\"large\""),
},
{
Raw: []byte("\"extra_large\""),
},
{
Raw: []byte("\"double_extra_large\""),
},
},
},
"clusterName": {
Description: "The clustername of the collector",
Type: "string",
},
"groupID": {
Description: "The groupId of the collector",
Type: "integer",
Minimum: &minGroupID,
},
"escalationChainID": {
Description: "The escalation chain Id of the collectors",
Type: "integer",
Minimum: &minValue,
},
"collectorVersion": {
Description: "The collector version (Fractional numbered version is invalid. For ex: 29.101 is invalid, correct input is 29101)",
Type: "integer",
Minimum: &minValue,
},
"labels": {
Description: "The Labels of the collector",
Type: "object",
AdditionalProperties: &apiextensionsv1.JSONSchemaPropsOrBool{
Schema: &apiextensionsv1.JSONSchemaProps{
Type: "string",
},
},
},
"annotations": {
Description: "The Annotations of the collector",
Type: "object",
AdditionalProperties: &apiextensionsv1.JSONSchemaPropsOrBool{
Schema: &apiextensionsv1.JSONSchemaProps{
Type: "string",
},
},
},
"useEA": {
Description: "Flag to opt for EA collector versions",
Type: "boolean",
},
"proxyURL": {
Description: "The Http/Https proxy url of the collector",
Type: "string",
},
"secretName": {
Description: "The Secret resource name of the collector",
Type: "string",
},
"statefulsetspec": {
Description: "The collector StatefulSet specification for customizations",
Type: "object",
XPreserveUnknownFields: &preserveUnknownFields,
Properties: map[string]apiextensionsv1.JSONSchemaProps{
"template": {
Type: "object",
Properties: map[string]apiextensionsv1.JSONSchemaProps{
"spec": {
Type: "object",
Properties: map[string]apiextensionsv1.JSONSchemaProps{
"nodeSelector": {
Type: "object",
AdditionalProperties: &apiextensionsv1.JSONSchemaPropsOrBool{
Schema: &apiextensionsv1.JSONSchemaProps{
Type: "string",
},
},
},
},
},
},
},
},
},
"policy": {
Type: "object",
Properties: map[string]apiextensionsv1.JSONSchemaProps{
"distributionStrategy": {
Description: "Distribution strategy to provide collector ID to the client requests from available running collectors",
Type: "string",
Default: &apiextensionsv1.JSON{
Raw: []byte("\"RoundRobin\""),
},
},
"orchestrator": {
Description: "The container orchestration platform designed to automate the deployment, scaling, and management of containerized applications",
Type: "string",
Default: &apiextensionsv1.JSON{
Raw: []byte("\"Kubernetes\""),
},
},
},
},
},
},
},
func getCustomResourceDefinationSchema() (*apiextensionsv1.JSONSchemaProps, error) {
schema := &apiextensionsv1.JSONSchemaProps{}
err := json.Unmarshal([]byte(schemaStr), schema)
if err != nil {
log.Errorf("Failed to parse schema definition: %v: %v", err, schemaStr)
return nil, fmt.Errorf("failed to parse schema definition: %w: %v", err, schemaStr)
}
log.Debugf("Unmarshaled schema: %v", schema)
return schema, nil
}

// CreateCustomResourceDefinition creates the CRD for collectors.
// nolint: gocyclo
func (c *Client) CreateCustomResourceDefinition() (*apiextensionsv1.CustomResourceDefinition, error) {
schema := &apiextensionsv1.CustomResourceValidation{}
preserveUnknownFields := true
schema.OpenAPIV3Schema = getCustomResourceDefinationSchema()
var err error
schema.OpenAPIV3Schema, err = getCustomResourceDefinationSchema()
if err != nil {
return nil, err
}
crd := &apiextensionsv1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: crdName,
Expand All @@ -264,6 +97,11 @@ func (c *Client) CreateCustomResourceDefinition() (*apiextensionsv1.CustomResour
Names: apiextensionsv1.CustomResourceDefinitionNames{
Plural: crv1alpha2.CollectorSetResourcePlural,
Kind: reflect.TypeOf(crv1alpha2.CollectorSet{}).Name(),
ShortNames: []string{
// cs is default shortname in kubernetes for ComponentStatuses, it is deprecated from 1.19+,
// when they remove it, we can use cs shortname here
"lmcs",
},
},
Scope: apiextensionsv1.NamespaceScoped,
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
Expand All @@ -289,7 +127,7 @@ func (c *Client) CreateCustomResourceDefinition() (*apiextensionsv1.CustomResour
},
}

_, err := c.APIExtensionsClientset.ApiextensionsV1().CustomResourceDefinitions().Create(crd)
_, err = c.APIExtensionsClientset.ApiextensionsV1().CustomResourceDefinitions().Create(crd)
if err != nil {
if apierrors.IsAlreadyExists(err) {
if err1 := c.updateCRD(crd); err1 != nil {
Expand Down
Loading