Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Merge pull request #275 from darkowlzz/k8s1.19-fixes
Browse files Browse the repository at this point in the history
k8s 1.19 fixes
  • Loading branch information
darkowlzz authored Sep 16, 2020
2 parents 99bff9e + b1f10ad commit f16e883
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.14.2
- image: circleci/golang:1.15.2

working_directory: /go/src/github.com/storageos/cluster-operator
steps:
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go:
env:
global:
- CHANGE_MINIKUBE_NONE_USER=true
- K8S_VERSION="v1.18.6"
- K8S_VERSION="v1.19.0"
- MINIKUBE_VERSION="v0.28.2"
- IMAGE_NAME=storageos/cluster-operator
- IMAGE_TAG=test
Expand Down Expand Up @@ -41,14 +41,14 @@ jobs:
sudo: required
env:
- "INSTALL_METHOD=olm"
name: OLM on KinD (k8s-1.18)
name: OLM on KinD (k8s-1.19)
script: ./test/e2e.sh $INSTALL_METHOD
- &base-test
go: "1.14"
sudo: required
env:
- "INSTALL_METHOD=none"
name: KinD (k8s-1.18)
name: KinD (k8s-1.19)
script: ./test/e2e.sh $INSTALL_METHOD
- stage: deploy
go: "1.14"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GO_BUILD_CMD = go build -v
GO_ENV = GOOS=linux CGO_ENABLED=0
SDK_VERSION = v0.17.2
MACHINE = $(shell uname -m)
BUILD_IMAGE = golang:1.14.2
BUILD_IMAGE = golang:1.15.2
BASE_IMAGE = storageos/base-image:0.2.1
BUILD_DIR = "build"
OPERATOR_SDK = $(BUILD_DIR)/operator-sdk
Expand All @@ -18,7 +18,7 @@ NEW_VERSION ?= v2.2.0
CACHE_DIR = $(shell pwd)/.cache
PROJECT = github.com/storageos/cluster-operator
GOARCH ?= amd64
GO_VERSION = 1.14.2
GO_VERSION = 1.15.2

# Since go modules don't allow non-go files to be vendored, the code generator
# scripts needed for updating the generated codes are downloaded in the cache
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=golang:1.14.2
ARG BUILD_IMAGE=golang:1.15.2
ARG BASE_IMAGE=storageos/base-image:0.2.1
ARG OPERATOR_IMAGE=storageos/cluster-operator:test

Expand Down
2 changes: 1 addition & 1 deletion build/rhel-build-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ARG BASE_IMAGE=storageos/base-image:0.2.1
# ARG OPERATOR_IMAGE=storageos/cluster-operator:test

FROM golang:1.14.2 AS build
FROM golang:1.15.2 AS build
# OPERATOR_IMAGE needs to be passed to operator make target for constructing
# the ldflags.
# ARG OPERATOR_IMAGE
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func NewSignedCert(cfg Config, key crypto.Signer, caCert *x509.Certificate, caKe
CommonName: cfg.CommonName,
Organization: cfg.Organization,
},
DNSNames: cfg.AltNames.DNSNames,
DNSNames: []string{cfg.CommonName},
IPAddresses: cfg.AltNames.IPs,
SerialNumber: serial,
NotBefore: caCert.NotBefore,
Expand Down
20 changes: 0 additions & 20 deletions pkg/storageos/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1624,26 +1624,6 @@ func TestDeploySchedulerExtender(t *testing.T) {
t.Errorf("expected %q to be in scheduler policy configmap data", policyConfigKey)
}

// Get scheduler configuration configmap and check the data.
schedConfigcm := &corev1.ConfigMap{}
schedConfigNSName := types.NamespacedName{
Name: schedulerConfigConfigMapName,
Namespace: defaultNS,
}

if err := c.Get(context.Background(), schedConfigNSName, schedConfigcm); err != nil {
t.Fatal("failed to get the created scheduler configuration configmap", err)
}

// Check if the expected key and value exists.
if val, exists := schedConfigcm.Data[schedulerConfigKey]; exists {
if len(val) == 0 {
t.Errorf("%q is empty, expected not to be empty", schedulerConfigKey)
}
} else {
t.Errorf("expected %q to be in scheduler configuration configmap data", schedulerConfigKey)
}

// Check the attributes of the scheduler deployment.
schedDeployment := &appsv1.Deployment{}
schedDeploymentNSName := types.NamespacedName{
Expand Down
90 changes: 7 additions & 83 deletions pkg/storageos/scheduler_extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import (
)

const (
policyConfigMapName = "storageos-scheduler-policy"
policyConfigKey = "policy.cfg"
schedulerConfigConfigMapName = "storageos-scheduler-config"
schedulerConfigKey = "config.yaml"
policyConfigMapName = "storageos-scheduler-policy"
policyConfigKey = "policy.cfg"

uriPathV1 = "/v1/scheduler"
uriPathV2 = "/v2/k8s/scheduler"
Expand All @@ -30,9 +28,6 @@ func (s *Deployment) createSchedulerExtender() error {
if err := s.createSchedulerPolicy(); err != nil {
return err
}
if err := s.createSchedulerConfiguration(); err != nil {
return err
}

// Create RBAC related resources.
if err := s.createClusterRoleForScheduler(); err != nil {
Expand Down Expand Up @@ -68,7 +63,6 @@ func (s Deployment) createSchedulerDeployment(replicas int32) error {
Spec: corev1.PodSpec{
ServiceAccountName: SchedulerSA,
Containers: s.schedulerContainers(),
Volumes: s.schedulerVolumes(),
},
},
}
Expand All @@ -94,30 +88,13 @@ func (s Deployment) schedulerContainers() []corev1.Container {
ImagePullPolicy: corev1.PullIfNotPresent,
Args: []string{
"kube-scheduler",
"--config=/storageos-scheduler/config.yaml",
"--leader-elect=true",
"--scheduler-name=" + SchedulerExtenderName,
"--policy-configmap=" + policyConfigMapName,
"--policy-configmap-namespace=" + s.stos.Spec.GetResourceNS(),
"--lock-object-name=" + SchedulerExtenderName,
"-v=4",
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "storageos-scheduler-config",
MountPath: "/storageos-scheduler",
},
},
},
}
}

// schedulerVolumes returns a list of volumes that should be part of the
// scheduler extender deployment.
func (s Deployment) schedulerVolumes() []corev1.Volume {
return []corev1.Volume{
{
Name: schedulerConfigConfigMapName,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: schedulerConfigConfigMapName},
},
},
},
}
}
Expand All @@ -131,9 +108,6 @@ func (s Deployment) deleteSchedulerExtender() error {
if err := s.k8sResourceManager.ConfigMap(policyConfigMapName, namespace, nil, nil).Delete(); err != nil {
return err
}
if err := s.k8sResourceManager.ConfigMap(schedulerConfigConfigMapName, namespace, nil, nil).Delete(); err != nil {
return err
}
if err := s.k8sResourceManager.ClusterRoleBinding(SchedulerClusterBindingName, nil, nil, nil).Delete(); err != nil {
return err
}
Expand Down Expand Up @@ -207,56 +181,6 @@ func (s Deployment) createSchedulerPolicy() error {
return s.k8sResourceManager.ConfigMap(policyConfigMapName, s.stos.Spec.GetResourceNS(), nil, data).Create()
}

// schedulerConfigTemplate contains fields for rendering the scheduler
// configuration.
type schedulerConfigTemplate struct {
SchedulerName string
PolicyName string
Namespace string
LeaderElection bool
}

// createSchedulerConfiguration creates a configmap with kube-scheduler
// configuration.
func (s Deployment) createSchedulerConfiguration() error {
configTemplate := `
apiVersion: "kubescheduler.config.k8s.io/v1alpha1"
kind: KubeSchedulerConfiguration
schedulerName: {{.SchedulerName}}
algorithmSource:
policy:
configMap:
namespace: {{.Namespace}}
name: {{.PolicyName}}
leaderElection:
leaderElect: {{.LeaderElection}}
lockObjectName: {{.SchedulerName}}
lockObjectNamespace: {{.Namespace}}
`
schedConfigData := schedulerConfigTemplate{
SchedulerName: SchedulerExtenderName,
PolicyName: policyConfigMapName,
Namespace: s.stos.Spec.GetResourceNS(),
LeaderElection: true,
}

// Render the scheduler configuration.
var schedConfig bytes.Buffer
tmpl, err := template.New("schedConfig").Parse(configTemplate)
if err != nil {
return err
}
if err := tmpl.Execute(&schedConfig, schedConfigData); err != nil {
return err
}

// Add the configuration in the configmap.
data := map[string]string{
"config.yaml": schedConfig.String(),
}
return s.k8sResourceManager.ConfigMap(schedulerConfigConfigMapName, s.stos.Spec.GetResourceNS(), nil, data).Create()
}

// podLabelsForScheduler returns labels for the scheduler pod.
func podLabelsForScheduler(name string) map[string]string {
// Combine CSI Helper specific labels with the default app labels.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -Eeuxo pipefail

readonly K8S_LATEST="v1.18.6"
readonly K8S_LATEST="v1.19.0"
readonly KIND_LINK="https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-linux-amd64"

OPERATOR_SDK="build/operator-sdk"
Expand Down

0 comments on commit f16e883

Please sign in to comment.