Skip to content

Instantly share code, notes, and snippets.

@apssouza22
Last active August 9, 2023 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apssouza22/c37bf75e8f1794407e752ac1a9f5aa85 to your computer and use it in GitHub Desktop.
Save apssouza22/c37bf75e8f1794407e752ac1a9f5aa85 to your computer and use it in GitHub Desktop.
Course - https://www.udemy.com/kubernetes-microservices
k8s example - https://github.com/apssouza22/k8s-microservices
Istio example - https://github.com/apssouza22/service-mesh-istio
## K8s commands
Delete all services
kubectl delete daemonsets,replicasets,services,deployments,pods,rc -n namespace-name —all
- kubectl describe pod pod_name
- kubectl delete pod pod_name
- kubectl port-forward conduit-frontend 8000:80 # Acessing the container
- kubectl expose deployment deployment_name —type=NodePort
- kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 & //Making Kiali acessable from outside the cluster
- kubectl exec -it pod_name bash
- kubectl attach pod_name # access the container
- kubectl label pods pod_name label_name=value
- kubectl run pod_name —image=image_name —port=5701
- kubectl get po -n authorization-entrypoint -w #watching pod changes
- kubectl logs <pod-name> -n <namespace> -f # real time logs
- kubectl logs <pod-name> -n <namespace> -c container_name
- kubectl logs podname -c containername --previous
- kubectl delete po pod_name -n ns_name --force --grace-period 0
- kubectl delete -f install/kubernetes/istio-demo.yaml # deleting the configuration
- kubectl get svc -n istio-system # listing services
- kubectl proxy #load the api
- kubectl get ingress --all-namespaces
- kubectl rollout undo deployment/frontend # Rollback to the previous deployment
- kubectl config set-context dev --namespace=jhipster --cluster=minikube --user=minikube # Assign dev context to development namespace
- kubectl config use-context dev # Switch to Dev context
## Minikube commands
- minikube start --cpus 4 --memory 8192
- minikube ip
- minikube status
- minikube dashboard
- minikube delete
- minikube addons list
- minikube addons enable ingress
- minikube update-context
-minikube start -h //help for the command
more useful commands https://gist.github.com/edsiper/fac9a816898e16fc0036f5508320e8b4
## Istio
Starting with Istio
https://istio.io/docs/setup/kubernetes/install/kubernetes/
Starting Istio
for i in ~/istio-1.2.2/install/kubernetes/helm/istio-init/files/crd*yaml; do kubectl apply -f $i; done
kubectl apply -f ~/istio-1.2.2/install/kubernetes/istio-demo.yaml
Deleting Istio demo
for i in ~/istio-1.2.2/install/kubernetes/helm/istio-init/files/crd*yaml; do kubectl delete -f $i; done
kubectl delete -f ~/istio-1.2.2/install/kubernetes/istio-demo.yaml
Get the Ingress gateway service details
kubectl get svc istio-ingressgateway -n istio-system
When you deploy your application using kubectl apply, the Istio sidecar injector will automatically inject Envoy containers into your application pods if they are started in namespaces labeled with istio-injection=enabled or run istioctl kube-inject -f <your-app-spec>.yaml:
kubectl label namespace <namespace> istio-injection=enabled
kubectl create -n <namespace> -f <your-app-spec>.yaml
Hipster app generate
jhipster import-jdl application.jdl
Ingress issue
From the ingress pod - curl -H "HOST: ingress.local" localhost
curl -H "HOST: ingress.local" 192.168.99.102
https://medium.com/@ManagedKube/kubernetes-troubleshooting-ingress-and-services-traffic-flows-547ea867b120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment