helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update && helm repo list
kubectl config get-contexts
Config
export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"
Install
helm show values bitnami/elasticsearch --version=21.4.0|less
helm show values bitnami/elasticsearch --version=21.4.1|less
kubectl get ns|grep elasticsearch
kubectl delete ns elasticsearch
kubectl create ns elasticsearch
|
kubectl get ns|grep elasticsearch
kubectl -n=elasticsearch create secret generic elasticsearch \
--from-literal=elasticsearch-password=sadaqah! \
--dry-run=client -o=yaml \
| kubectl apply -f=-
|
|
cat <<ENV | kubectl -n=elasticsearch create secret generic elasticsearch --from-env-file=/dev/stdin
elasticsearch-password=sadaqah!
ENV
|
|
cat << YML | kubectl -n=elasticsearch apply -f=-
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-elasticsearch
spec:
persistentVolumeReclaimPolicy: Retain
storageClassName: standard
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /tmp/hostpath-provisioner/elasticsearch/pvc-elasticsearch
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: elasticsearch
name: pvc-elasticsearch
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
volumeName: pv-elasticsearch
YML
|
cat << YML | kubectl -n=elasticsearch apply -f=-
---
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: elasticsearch
name: pvc-elasticsearch
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
YML
|
|
PV_NAME="$(kubectl -n=elasticsearch get pvc pvc-elasticsearch -o=yaml|yq -r .spec.volumeName)"
cat <<YML |kubectl -n=elasticsearch patch pv ${PV_NAME} --patch-file=/dev/stdin
---
spec:
persistentVolumeReclaimPolicy: Retain
YML
|
|
cat <<YML | helm -n=elasticsearch install elasticsearch bitnami/elasticsearch --version=21.4.1 -f=-
---
ingress:
path: /
enabled: true
ingressClassName: nginx
hostname: elasticsearch.k8s.local
security:
existingSecret: elasticsearch
master:
masterOnly: false
replicaCount: 1
data:
replicaCount: 0
ingest:
replicaCount: 0
coordinating:
replicaCount: 0
YML
|
|
xdg-open http://elasticsearch.k8s.local &>/dev/null &
gnome-open http://elasticsearch.k8s.local &>/dev/null &
|
x-www-browser http://elasticsearch.k8s.local &>/dev/null &
sensible-browser http://elasticsearch.k8s.local &>/dev/null &
|
Uninstall
helm uninstall -n=elasticsearch elasticsearch
kubectl delete namespace elasticsearch
Playground
helm -n=elasticsearch install elasticsearch bitnami/elasticsearch --version=21.4.0
helm -n=elasticsearch upgrade -i elasticsearch bitnami/elasticsearch --version=21.4.1
helm show values bitnami/elasticsearch --version=21.4.1|less
|
|
kubectl -n=elasticsearch exec -it svc/elasticsearch -c=elasticsearch-coordinating-0 -- sh
kubectl -n=elasticsearch exec -it svc/elasticsearch -c=elasticsearch-master-0 -- sh
|
|
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten
|
|
kubectl -n=elasticsearch delete all --all
kubectl -n=elasticsearch delete ing --all
kubectl -n=elasticsearch delete sts --all
|
kubectl -n=elasticsearch delete svc --all
kubectl -n=elasticsearch delete pvc --all
kubectl -n=elasticsearch delete pv --all
|
|
kubectl -n=elasticsearch rollout history deploy elasticsearch
kubectl -n=elasticsearch rollout restart deploy elasticsearch
kubectl -n=elasticsearch rollout status deploy elasticsearch
|
kubectl -n=elasticsearch logs -f svc/elasticsearch -c=elasticsearch-master-0
kubectl -n=elasticsearch exec -it svc/elasticsearch -- sh
kubectl -n=elasticsearch logs -f svc/elasticsearch
|
References