Last active
          April 20, 2021 19:22 
        
      - 
      
- 
        Save smijar/4304fa6756dd03c0cd323d45a0c7e6bd to your computer and use it in GitHub Desktop. 
    Makefile for simplified k3s deploy on local
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | create_dev_cluster: | |
| k3d create --name dev --api-port 6443 --publish 8081:80 --workers 2 | |
| # add the metrics-server | |
| kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.4.2/components.yaml | |
| list: | |
| k3d list | |
| switch_dev: | |
| export KUBECONFIG="$(k3d get-kubeconfig --name='dev')" | |
| kubectl cluster-info | |
| kubectl get nodes | |
| test_dev: | |
| # from: https://raw.githubusercontent.com/myannou/k3d-demo/master/nginx.yaml | |
| kubectl apply -f ./nginx.yaml | |
| @echo sleeping until deployment is done... | |
| sleep 10 | |
| @echo testing... | |
| curl -I http://localhost:8081 | |
| @echo worked... | |
| clean_dev: | |
| kubectl delete -f ./nginx.yaml | |
| top: | |
| kubectl top node | |
| kubectl top pod --all-namespaces | |
| stop_dev: | |
| k3d stop --name=dev | |
| delete_dev_cluster: | |
| k3d delete --name=dev | |
| local_registry: | |
| docker volume create local_registry | |
| docker container run -d --name registry.localhost -v local_registry:/var/lib/registry --restart always -p 5000:5000 registry:2 | |
| #docker network connect k3d-k3s-default registry.localhost | |
| docker network connect k3d-dev registry.localhost | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| labels: | |
| app: nginx | |
| name: nginx | |
| spec: | |
| replicas: 2 | |
| selector: | |
| matchLabels: | |
| app: nginx | |
| template: | |
| metadata: | |
| labels: | |
| app: nginx | |
| spec: | |
| containers: | |
| - image: nginx | |
| name: nginx | |
| ports: | |
| - containerPort: 80 | |
| protocol: TCP | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: nginx | |
| spec: | |
| ports: | |
| - port: 80 | |
| protocol: TCP | |
| targetPort: 80 | |
| selector: | |
| app: nginx | |
| sessionAffinity: None | |
| type: ClusterIP | |
| --- | |
| apiVersion: extensions/v1beta1 | |
| kind: Ingress | |
| metadata: | |
| name: nginx | |
| annotations: | |
| ingress.kubernetes.io/ssl-redirect: "false" | |
| spec: | |
| rules: | |
| - http: | |
| paths: | |
| - path: / | |
| backend: | |
| serviceName: nginx | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment