Skip to content

Commit

Permalink
Merge pull request #68 from FabianKramm/main
Browse files Browse the repository at this point in the history
refactor: remove leader election annotation & refactor devspace yaml
  • Loading branch information
FabianKramm authored Jul 1, 2021
2 parents dad2407 + 794c6ae commit fa65bf5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 70 deletions.
89 changes: 24 additions & 65 deletions devspace.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
version: v1beta10
vars:
- name: IMAGE
value: ghcr.io/loft-sh/loft-enterprise/dev-vcluster
- name: K3S
value: rancher/k3s:v1.20.5-k3s1
- name: SERVICE_CIDR
value: 10.96.0.0/12
images:
vcluster:
image: ghcr.io/loft-sh/loft-enterprise/dev-vcluster
image: ${IMAGE}
rebuildStrategy: ignoreContextChanges
entrypoint: ["sleep", "99999999"]
entrypoint: ["sleep", "999999999"]
build:
docker:
skipPush: true
Expand All @@ -19,9 +26,9 @@ deployments:
create: false
name: default
vcluster:
image: rancher/k3s:v1.20.5-k3s1
image: ${K3S}
extraArgs:
- --service-cidr=10.96.0.0/12
- --service-cidr=${SERVICE_CIDR}
rbac:
clusterRole:
create: true
Expand All @@ -30,88 +37,40 @@ deployments:
enabled: false
livenessProbe:
enabled: false
image: ghcr.io/loft-sh/loft-enterprise/dev-vcluster
image: ${IMAGE}
noArgs: true
dev:
terminal:
imageName: vcluster
imageSelector: ${IMAGE}
sync:
- imageName: vcluster
disableDownload: true
waitInitialSync: true
- imageSelector: ${IMAGE}
excludePaths:
- bin/
- .vscode/
- .idea/
- .git/
- docs/
- examples/
- /conformance
- /hack
- /test
- /chart
- /helm
- /kubectl
- /vendor/github.com/devspace-cloud/
- '**'
- '!/pkg'
- '!/cmd'
- '!/vendor'
- '!/go.mod'
- '!/go.sum'
commands:
- name: dev
command: "devspace dev -n vcluster"
- name: gke
command: "devspace dev -n vcluster -p gke"
- name: deploy
command: "devspace deploy --profile deploy -n vcluster -d"
profiles:
- name: gke
patches:
- path: dev.terminal
op: replace
value:
containerName: syncer
labelSelector:
app: vcluster
- path: dev.replacePods
op: replace
value:
- labelSelector:
app: vcluster
containerName: syncer
replaceImage: golang:1.16
patches:
- path: spec.containers[1].livenessProbe
op: remove
- path: spec.containers[1].readinessProbe
op: remove
- path: spec.containers[1].workingDir
op: replace
value: /vcluster
- path: spec.containers[1].command
op: replace
value: ["sleep", "99999999999"]
- path: dev.sync[0].imageName
op: remove
- path: images.vcluster
op: remove
- path: dev.sync[0].containerName
op: replace
value: syncer
- path: dev.sync[0].labelSelector
op: replace
value:
app: vcluster
- name: deploy
replace:
images:
vcluster:
image: ghcr.io/loft-sh/loft-enterprise/dev-vcluster
image: ${IMAGE}
deployments:
- name: vcluster
helm:
chart:
name: ./chart
values:
vcluster:
image: rancher/k3s:v1.20.5-k3s1
image: ${K3S}
extraArgs:
- --service-cidr=10.96.0.0/12
- --service-cidr=${SERVICE_CIDR}
syncer:
image: ghcr.io/loft-sh/loft-enterprise/dev-vcluster
image: ${IMAGE}
19 changes: 14 additions & 5 deletions pkg/controllers/resources/endpoints/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,36 +137,45 @@ func (s *syncer) translate(vObj runtime.Object) (*corev1.Endpoints, error) {
}
}

// make sure we delete the control-plane.alpha.kubernetes.io/leader annotation
// that will disable endpoint slice mirroring otherwise
if endpoints.Annotations != nil {
delete(endpoints.Annotations, "control-plane.alpha.kubernetes.io/leader")
}

return endpoints, nil
}

func (s *syncer) calcEndpointsDiff(pObj, vObj *corev1.Endpoints) (*corev1.Endpoints, error) {
var updated *corev1.Endpoints

// check subsets
// translate endpoints
translated, err := s.translate(vObj)
if err != nil {
return nil, err
}

// check subsets
if !equality.Semantic.DeepEqual(translated.Subsets, pObj.Subsets) {
updated = pObj.DeepCopy()
updated.Subsets = translated.Subsets
}

// check annotations
if !equality.Semantic.DeepEqual(vObj.Annotations, pObj.Annotations) {
if !equality.Semantic.DeepEqual(translated.Annotations, pObj.Annotations) {
if updated == nil {
updated = pObj.DeepCopy()
}
updated.Annotations = vObj.Annotations
updated.Annotations = translated.Annotations
}

// check labels
if !translate.LabelsEqual(vObj.Namespace, vObj.Labels, pObj.Labels) {
if !equality.Semantic.DeepEqual(translated.Labels, pObj.Labels) {
if updated == nil {
updated = pObj.DeepCopy()
}
updated.Labels = translate.TranslateLabels(vObj.Namespace, vObj.Labels)

updated.Labels = translated.Labels
}

return updated, nil
Expand Down

0 comments on commit fa65bf5

Please sign in to comment.