Skip to content

Adding kubernetes backend to stolon-chart#20

Merged
lwolf merged 7 commits intolwolf:masterfrom
Flowkap:master
Apr 9, 2018
Merged

Adding kubernetes backend to stolon-chart#20
lwolf merged 7 commits intolwolf:masterfrom
Flowkap:master

Conversation

@Flowkap
Copy link
Copy Markdown
Contributor

@Flowkap Flowkap commented Mar 29, 2018

Details can be found in issue #18

Copy link
Copy Markdown
Owner

@lwolf lwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, I left few minor comments inline to make sure we don't forget to cleanup.

During testing on my cluster I noticed one weird thing happening to stolon pods when I use kubernetes backend. If I run kubectl get pods -w output constantly getting updated.
https://gist.github.com/lwolf/2981232c2ccaa87e3d15681bcc425fe0
It does not happen if I use etcd as backend on the same cluster. Do you observe the same thing?

Comment thread stolon/README.md Outdated
### Experimental kubernetes backend:

```bash
$ git clone https://github.com/lwolf/stolon-chart
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove this duplicate installation steps, except for the helm install one.

Comment thread stolon/README.md
| `clusterName` | Name of the cluster | `kube-stolon` |
| `debug` | Debug mode | `false` |
| `store.backend` | Store backend to use (etcd/consul) | `etcd` |
| `store.backend` | Store backend to use (etcd/consul/kubernetes) | `etcd` |
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add second option - kubeResourceKind, with default and only possible - configmap

- --cluster-name={{ template "stolon.clusterName" . }}
- --store-backend={{ .Values.store.backend }}
{{- if eq .Values.store.backend "kubernetes" }}
- --kube-resource-kind={{ .Values.store.kubeRessourceKind }}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please change it to have configmap as default value, with possibility to override from .Values.store.kubeRessourceKind
i.e.
- --kube-resource-kind={{ default "configmap" .Values.store.kubeRessourceKind }}

Comment thread stolon/values.yaml Outdated
## ref: https://hub.docker.com/r/sorintlab/stolon/tags/
##
imageTag: "v0.9.0-pg9.6"
##
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v.0.10 is released now, please set it as default, and remove following comments.

Comment thread stolon/templates/sentinel-deploy.yaml Outdated
value: {{ .Values.store.backend | quote}}
{{- if eq .Values.store.backend "kubernetes" }}
- name: STSENTINEL_KUBE_RESOURCE_KIND
value: {{ .Values.store.kubeRessourceKind | quote}}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add default value here as well

Comment thread stolon/templates/proxy-deploy.yaml Outdated
value: {{ .Values.store.backend | quote}}
{{- if eq .Values.store.backend "kubernetes" }}
- name: STPROXY_KUBE_RESOURCE_KIND
value: {{ .Values.store.kubeRessourceKind | quote}}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add default value here as well

value: {{ .Values.store.backend | quote}}
{{- if eq .Values.store.backend "kubernetes" }}
- name: STKEEPER_KUBE_RESOURCE_KIND
value: {{ .Values.store.kubeRessourceKind | quote}}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add default value here as well

Comment thread stolon/values.yaml Outdated
## store endpoints MUST be set!
endpoints: "http://etcd-etcd-0.etcd-etcd:2379,http://etcd-etcd-1.etcd-etcd:2379,http://etcd-etcd-2.etcd-etcd:2379"

## kubernetes You also need the new imageTag! (should work, use at own risk, new feature as of https://github.com/sorintlab/stolon/pull/433)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this entire block could be removed since we already have backend field on top and kubeResourceKind will have default value.

selector:
# Due to https://github.com/sorintlab/stolon/pull/433/commits/38ae6b13b5e161a5bfe0fbe01084ca060eaf2e76#diff-95cdd374e9440fde010ff35d65f8cf3fR54
{{- if eq .Values.store.backend "kubernetes" }}
app: "stolon-keeper"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With current condition we could not have 2 stolon clusters deployed in the same namespace with kubernetes backend.
Let's change labelling to be unified.

selector:
  app=stolon-keeper
  component: keeper
  release: "{{ .Release.Name }}"

and we should remove if-else in all deployments/daemonsets.

Copy link
Copy Markdown
Contributor Author

@Flowkap Flowkap Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did deploy two clusters in same namespace for K8. why'd you think this does not work?
Anyway, this could be a good approach to remove cluttered if statements. I introduced them in the first place in order to not change existing behaviour.

Also stolon-cluster label is necessary on specs as well in order for the service discovery to work. I also filed sorintlab/stolon#466

I'll change it according to your proposal. Might also be a solution to avoid the matching problematics.

Also I think I'll remove obsolete labels to remove unnecessary double lables. If applicable.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without suggested rework of labels, services in both clusters will endup balancing traffic between all keepers (If I don't miss anything):

  selector:
    app: stolon-keeper
    component: keeper

https://github.com/lwolf/stolon-chart/blob/master/stolon/templates/keeper-ro-service.yaml#L18-L20

Comment thread stolon/values.yaml Outdated

## kubernetes You also need the new imageTag! (should work, use at own risk, new feature as of https://github.com/sorintlab/stolon/pull/433)
# backend: "kubernetes"
# kubeRessourceKind: "configmap"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that you have typo in kubeRessourceKind which is copypasted everywhere.
kubeRessourceKind => kubeResourceKind

@lwolf
Copy link
Copy Markdown
Owner

lwolf commented Mar 30, 2018

Just made a diff of the same resource after few seconds.
resourceVersion and metadata.annotations.stolon-status are constantly getting change.

@lwolf
Copy link
Copy Markdown
Owner

lwolf commented Mar 30, 2018

I can confirm that the issue is present is original examples of stolon, so I'm going to create issue about it there.

- name: STKEEPER_PG_SU_PASSWORDFILE
value: "/etc/secrets/stolon/pg_su_password"
- name: STSENTINEL_DEBUG
- name: STKEPPER_DEBUG
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Should be STKEEPER_DEBUG

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed typo and added a typo... Fail ... :D

@Flowkap
Copy link
Copy Markdown
Contributor Author

Flowkap commented Apr 3, 2018

I can confirm the continuous change of the resources as well. I'll later go through all your valid comments and try out if the labeling is fixed (seems to be at least in master)

@Flowkap
Copy link
Copy Markdown
Contributor Author

Flowkap commented Apr 3, 2018

Updated the PR

release: "{{ .Release.Name }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: "{{ .Release.Service }}"
component: keeper
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, keep component label in place, just set it to the same value as current app.

Hopefully your RFE will be addressed inside the stolon repo, and we could reverse app label later. Essentially it is more logical to have app label corresponding to the fullname and component to, well, component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should it be there? It's only useful on pods right?

I intentionally removed component + stolon-cluster labels from all spec excluding pods, as well as I removed chart and heritage from pods in order to not have all labels doubled in the chart templates.

Maybe I'm missing something

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not intended I add component and the stolon-cluster label to all labels sections again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

app: {{ template "stolon.keeper.fullname" . }}
app: "stolon-keeper"
release: "{{ .Release.Name }}"
component: keeper
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you did not delete component from label selector, but did delete it from the labels in keeper.

Copy link
Copy Markdown
Contributor Author

@Flowkap Flowkap Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component is still in place in all pod specs which are used for selection. I only deleted the cluster-name as well as component from the StatefulSets and according resources. K8 service discovery works fine for keepers as is.

Comment thread stolon/values.yaml Outdated
backend: "etcdv3"
## store endpoints MUST be set!
endpoints: "http://etcd-etcd-0.etcd-etcd:2379,http://etcd-etcd-1.etcd-etcd:2379,http://etcd-etcd-2.etcd-etcd:2379"
## for kubernetes backend (experimental)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comments

@Flowkap
Copy link
Copy Markdown
Contributor Author

Flowkap commented Apr 4, 2018

I added the RBAC stuff as well. I left the two open points in regard to the labels open and wait for your response first.

Copy link
Copy Markdown
Owner

@lwolf lwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left one comment about labels, but I'll take another look tomorrow

@@ -4,24 +4,21 @@ metadata:
name: {{ template "stolon.sentinel.fullname" . }}
labels:
app: {{ template "stolon.sentinel.fullname" . }}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reasoning behind having half of the components with hardcoded app label and half with templated as before?

Copy link
Copy Markdown
Owner

@lwolf lwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put all of the labels in the google-doc:
https://docs.google.com/spreadsheets/d/1pXjzZEElWs6Dib7qrxGdHHF_61OOhiCKYlTWVhvi4mw/edit?usp=sharing
 
I see your point about redundant labels on pods, and I'm fine with removing heritage from pods. But I still prefer to have component and chart labels everywhere. This labels are useful for manual selection.

labels:
app: {{ template "stolon.keeper.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: "stolon-keeper"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this should be app: {{ template "stolon.keeper.fullname" . }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Comment thread stolon/templates/keeper-ro-service.yaml Outdated
labels:
app: {{ template "stolon.keeper.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: "stolon-keeper"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this should be app: {{ template "stolon.keeper.fullname" . }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@Flowkap
Copy link
Copy Markdown
Contributor Author

Flowkap commented Apr 9, 2018

Sorry I was sick the last few days.

I see your point about redundant labels on pods, and I'm fine with removing heritage from pods. But I still prefer to have component and chart labels everywhere. This labels are useful for manual selection.

Ok see that as well. Will change it as well as fix the two wrong labels you mentioned above :)

@Flowkap
Copy link
Copy Markdown
Contributor Author

Flowkap commented Apr 9, 2018

Shall we wait for sorintlab/stolon#466 to resolve until merge or change it when it's finished (don't know when this could be part of a next release)

We anyway already use my fork for internal testing as our system is under heavy development still. I would'nt mind.

@lwolf
Copy link
Copy Markdown
Owner

lwolf commented Apr 9, 2018

Let's release it as is, and update labels if and when that issue is resolved.
Thank you for the work on this.

@lwolf lwolf merged commit d42a1c5 into lwolf:master Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants