Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crd1 #66

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Crd1 #66

Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ orbs:
jobs:
markdownlint:
docker:
- image: circleci/node:10.14.2
- image: cimg/node:18.14.1
auth:
username: ${DOCKER_USERNAME}
password: ${DOCKER_PASSWORD}
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
- run:
name: docker login
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- run:
name: docker build and push
command: |
Expand Down
12 changes: 10 additions & 2 deletions example/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,28 @@ metadata:
namespace: sensu

---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: sensu-operator
namespace: sensu
spec:
replicas: 1
selector:
matchLabels:
app: sensu-operator
release: sensu-operator
template:
metadata:
labels:
name: sensu-operator
release: sensu-operator
app: sensu-operator
spec:
containers:
- name: sensu-operator
image: objectrocket/sensu-operator:latest
imagePullPolicy: Never
imagePullPolicy: Always
env:
- name: MY_POD_NAMESPACE
valueFrom:
Expand All @@ -49,3 +55,5 @@ spec:
value: "4"
- name: SENSUOP_PROCESSING_RETRIES
value: "5"
imagePullSecrets:
- name: 'or-docker-secret'
12 changes: 7 additions & 5 deletions example/example-sensu-cluster-objectrocket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: SensuCluster
metadata:
annotations:
objectrocket.com/scope: clusterwide
name: platdev0
name: sensu
namespace: sensu
spec:
pod:
Expand All @@ -14,7 +14,9 @@ spec:
resources:
requests:
storage: 8Gi
storageClassName: standard
repository: sensu/sensu
size: 1
version: 5.14.0
storageClassName: gp2
repository: objectrocket/sensu-backend
size: 5
version: 5.20.2_or2
clusteradminusername: admin
clusteradminpassword: p@ssw0rd!
1 change: 1 addition & 0 deletions helm/sensu-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apiVersion: v1
name: sensu-operator
version: 0.0.0
description: ObjectRocket Sensu Operator
Expand Down
13 changes: 6 additions & 7 deletions helm/sensu-operator/templates/sensu-operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ spec:
imagePullSecrets:
- name: {{ .Values.imagePullSecret.name }}
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
allowPrivilegeEscalation: false
runAsNonRoot: true
supplementalGroups:
- 1000
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
runAsNonRoot: true
supplementalGroups:
- 1000
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
Expand Down
8 changes: 4 additions & 4 deletions helm/sensu-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ resourceSettings:

logLevel: info

nodeSelector:
node-role.kubernetes.io/platform_worker: "true"
#nodeSelector:
# node-role.kubernetes.io/platform_worker: "true"

tolerations:
- effect: NoSchedule
key: node_role
operator: Equal
value: platform_worker
value: product_worker

rbac:
clusterRole: sensu-operator
Expand All @@ -53,4 +53,4 @@ sensu:
processingRetries: 5

prometheus:
enabled: true
enabled: false
2 changes: 1 addition & 1 deletion pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (c *Cluster) ClientURLs(m *etcdutil.MemberConfig) (urls []string) {
}

func (c *Cluster) PeerURL(m *etcdutil.MemberConfig, ordinalID int) string {
return fmt.Sprintf("%s://%s.%s.%s.svc:2380",
return fmt.Sprintf("%s://%s.%s.%s.svc.cluster.local:2380",
m.PeerScheme(),
c.memberName(ordinalID),
c.name(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/sensu_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *SensuClient) SetTimeout(t time.Duration) {
}

func (s *SensuClient) makeFullyQualifiedSensuClientURL() string {
return fmt.Sprintf("%s.%s.svc", k8sutil.APIServiceName(s.clusterName), s.namespace)
return fmt.Sprintf("%s.%s.svc.cluster.local", k8sutil.APIServiceName(s.clusterName), s.namespace)
}

func (s *SensuClient) ensureCredentials() (err error) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/sensu_client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *sensuAPITestClient) CreateNamespace(ns *types.Namespace) error {
func TestNew(t *testing.T) {
conf := basic.Config{
Cluster: basic.Cluster{
APIUrl: "http://testCluster-api.testnamespace.svc:8080",
APIUrl: "http://testCluster-api.testnamespace.svc.cluster.local:8080",
},
Profile: basic.Profile{
Format: "json",
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestNew(t *testing.T) {
func TestSensuClient_makeFullyQualifiedSensuClientURL(t *testing.T) {
conf := basic.Config{
Cluster: basic.Cluster{
APIUrl: "http://testCluster.testnamespace.svc:8080",
APIUrl: "http://testCluster.testnamespace.svc.cluster.local:8080",
},
Profile: basic.Profile{
Format: "json",
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestSensuClient_makeFullyQualifiedSensuClientURL(t *testing.T) {
Logger: logger,
},
},
"testCluster-api.testnamespace.svc",
"testCluster-api.testnamespace.svc.cluster.local",
},
}
for _, tt := range tests {
Expand All @@ -159,7 +159,7 @@ func TestSensuClient_makeFullyQualifiedSensuClientURL(t *testing.T) {
func TestSensuClient_ensureCredentials(t *testing.T) {
conf := basic.Config{
Cluster: basic.Cluster{
APIUrl: "http://testCluster.testnamespace.svc:8080",
APIUrl: "http://testCluster.testnamespace.svc.cluster.local:8080",
Tokens: &types.Tokens{
Access: "fake",
},
Expand All @@ -171,7 +171,7 @@ func TestSensuClient_ensureCredentials(t *testing.T) {
}
confNoToken := basic.Config{
Cluster: basic.Cluster{
APIUrl: "http://testCluster.testnamespace.svc:8080",
APIUrl: "http://testCluster.testnamespace.svc.cluster.local:8080",
},
Profile: basic.Profile{
Format: "json",
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestSensuClient_ensureCredentials(t *testing.T) {
func TestSensuClient_ensureNamespace(t *testing.T) {
conf := basic.Config{
Cluster: basic.Cluster{
APIUrl: "http://testCluster.testnamespace.svc:8080",
APIUrl: "http://testCluster.testnamespace.svc.cluster.local:8080",
Tokens: &types.Tokens{
Access: "fake",
},
Expand Down
16 changes: 11 additions & 5 deletions pkg/util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ etcd-key-file: %[1]s/server.key
Name: "etcsensu",
MountPath: "/etc/sensu",
}
/*configVolumeMountData := v1.VolumeMount{
Name: "etcd-data",
MountPath: "/var/lib/sensu/etcd",
}*/

container := containerWithProbes(
sensuContainer(strings.Split(commands, " "), cs.Repository, cs.Version, cs.ClusterAdminUsername, cs.ClusterAdminPassword),
livenessProbe,
Expand Down Expand Up @@ -564,7 +569,7 @@ etcd-key-file: %[1]s/server.key
TIMEOUT_READY=%d
SUBDOMAIN=%s
NAMESPACE=%s
LOCAL_HOSTNAME=$(hostname).${SUBDOMAIN}.${NAMESPACE}.svc
LOCAL_HOSTNAME=$(hostname).${SUBDOMAIN}.${NAMESPACE}.svc.cluster.local
while ( ! nslookup $LOCAL_HOSTNAME )
do
# If TIMEOUT_READY is 0 we should never time out and exit
Expand Down Expand Up @@ -595,9 +600,9 @@ ORDINAL=${HOSTNAME##*-}
TOKEN=%s
SUBDOMAIN=%s
NAMESPACE=%s
LOCAL_HOSTNAME=${HOSTNAME}.${SUBDOMAIN}.${NAMESPACE}.svc
LOCAL_HOSTNAME=${HOSTNAME}.${SUBDOMAIN}.${NAMESPACE}.svc.cluster.local
SEED_NAME=${SUBDOMAIN}-0
SEED_HOSTNAME=${SEED_NAME}.${SUBDOMAIN}.${NAMESPACE}.svc
SEED_HOSTNAME=${SEED_NAME}.${SUBDOMAIN}.${NAMESPACE}.svc.cluster.local
INITIAL_CLUSTER="${SEED_NAME}=http://${SEED_HOSTNAME}:2380"
STATE="new"
if [[ "$ORDINAL" == "0" ]]
Expand All @@ -607,7 +612,7 @@ else
STATE="existing"
for i in $(seq 1 $ORDINAL)
do
INITIAL_CLUSTER=${INITIAL_CLUSTER},${SUBDOMAIN}-${i}=http://${SUBDOMAIN}-${i}.${SUBDOMAIN}.${NAMESPACE}.svc:2380
INITIAL_CLUSTER=${INITIAL_CLUSTER},${SUBDOMAIN}-${i}=http://${SUBDOMAIN}-${i}.${SUBDOMAIN}.${NAMESPACE}.svc.cluster.local:2380
done
fi
if [[ "${STATE}" == "new" ]]
Expand All @@ -621,6 +626,7 @@ cat /etc/sensu/backend.yml
`, token, clusterName, m.Namespace, options)},
VolumeMounts: []v1.VolumeMount{configVolumeMount},
},

},
Containers: []v1.Container{container},
RestartPolicy: v1.RestartPolicyAlways,
Expand Down Expand Up @@ -682,7 +688,7 @@ func InClusterConfig() (*rest.Config, error) {
// Work around https://github.com/kubernetes/kubernetes/issues/40973
// See https://github.com/sensu/sensu-operator/issues/731#issuecomment-283804819
if len(os.Getenv("KUBERNETES_SERVICE_HOST")) == 0 {
addrs, err := net.LookupHost("kubernetes.default.svc")
addrs, err := net.LookupHost("kubernetes.default.svc.cluster.local")
if err != nil {
panic(err)
}
Expand Down