Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Created December 14, 2019 17:13
Show Gist options
  • Save vfarcic/594a4a2e922f4722d4c83c9595b3d6eb to your computer and use it in GitHub Desktop.
Save vfarcic/594a4a2e922f4722d4c83c9595b3d6eb to your computer and use it in GitHub Desktop.
cd k8s-specs
git pull
GD5_ADDR=go-demo-5.$LB_IP.nip.io
echo $GD5_ADDR
kubectl create namespace go-demo-5
helm install go-demo-5 \
https://github.com/vfarcic/go-demo-5/releases/download/0.0.1/go-demo-5-0.0.1.tgz \
--namespace go-demo-5 \
--set ingress.host=$GD5_ADDR
kubectl -n go-demo-5 \
rollout status deployment go-demo-5
curl "http://$GD5_ADDR/demo/hello"
kubectl -n go-demo-5 \
describe sts go-demo-5-db
kubectl -n go-demo-5 \
logs go-demo-5-db-0 -c db
kubectl -n go-demo-5 \
logs -l app=go-demo-5
open "https://papertrailapp.com/"
open "https://papertrailapp.com/start"
PT_HOST=[...]
PT_PORT=[...]
cat logging/fluentd-papertrail.yml
cat logging/fluentd-papertrail.yml \
| sed -e \
"s@logsN.papertrailapp.com@$PT_HOST@g" \
| sed -e \
"s@NNNNN@$PT_PORT@g" \
| kubectl apply -f - --record
kubectl -n logging \
rollout status ds fluentd-papertrail
cat logging/logger.yml
kubectl create -f logging/logger.yml
kubectl logs random-logger
kubectl delete \
-f logging/fluentd-papertrail.yml
# Only if using GKE
kubectl -n kube-system \
describe ds -l k8s-app=fluentd-gcp
# Only if using GKE
kubectl -n kube-system \
logs -l k8s-app=fluentd-gcp \
-c fluentd-gcp
# Only if using GKE
open "https://console.cloud.google.com/logs/viewer"
# Only if using EKS
PROFILE=$(aws iam \
list-instance-profiles \
| jq -r \
".InstanceProfiles[]\
.InstanceProfileName" \
| grep eksctl-$NAME-nodegroup-0)
# Only if using EKS
echo $PROFILE
# Only if using EKS
ROLE=$(aws iam get-instance-profile \
--instance-profile-name $PROFILE \
| jq -r ".InstanceProfile.Roles[] \
| .RoleName")
# Only if using EKS
echo $ROLE
# Only if using EKS
cat logging/eks-logs-policy.json
# Only if using EKS
aws iam put-role-policy \
--role-name $ROLE \
--policy-name eks-logs \
--policy-document file://logging/eks-logs-policy.json
# Only if using EKS
aws iam get-role-policy \
--role-name $ROLE \
--policy-name eks-logs
# Only if using EKS
cat logging/fluentd-eks.yml
# Only if using EKS
kubectl apply \
-f logging/fluentd-eks.yml
# Only if using EKS
kubectl -n logging get pods
# Only if using EKS
open "https://$AWS_DEFAULT_REGION.console.aws.amazon.com/cloudwatch/home?#logStream:group=/eks/$NAME/containers"
# Only if using EKS
kubectl delete \
-f logging/fluentd-eks.yml
# Only if using EKS
aws iam delete-role-policy \
--role-name $ROLE \
--policy-name eks-logs
# Only if using EKS
aws logs delete-log-group \
--log-group-name \
"/eks/devops25/containers"
# Only if using AKS
az aks enable-addons \
-a monitoring \
-n devops25-cluster \
-g devops25-group
# Only if using AKS
kubectl -n kube-system get deployments
# Only if using AKS
open "https://portal.azure.com"
# Only if using AKS
az aks disable-addons \
-a monitoring \
-n devops25-cluster \
-g devops25-group
cat logging/es-values.yml
kubectl create namespace logging
helm upgrade -i elasticsearch \
stable/elasticsearch \
--version 1.32.1 \
--namespace logging \
--values logging/es-values.yml
kubectl -n logging \
rollout status \
deployment elasticsearch-client
helm upgrade -i fluentd \
stable/fluentd-elasticsearch \
--version 2.0.7 \
--namespace logging \
--values logging/fluentd-values.yml
kubectl -n logging \
rollout status \
ds fluentd-fluentd-elasticsearch
kubectl -n logging logs \
-l app.kubernetes.io/instance=fluentd
cat logging/kibana-values.yml
KIBANA_ADDR=kibana.$LB_IP.nip.io
helm upgrade -i kibana \
stable/kibana \
--version 3.2.5 \
--namespace logging \
--set ingress.hosts="{$KIBANA_ADDR}" \
--values logging/kibana-values.yml
kubectl -n logging \
rollout status \
deployment kibana
open "http://$KIBANA_ADDR"
helm delete kibana \
--namespace logging
helm delete fluentd \
--namespace logging
helm delete elasticsearch \
--namespace logging
kubectl -n logging \
delete pvc \
-l release=elasticsearch,component=data
kubectl -n logging \
delete pvc \
-l release=elasticsearch,component=master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment