Skip to main content
  1. Tech/

How to backup Kubernetes' Config

·1 min

The easiest solution seems to be the following script by Stack Overflow user, Timothy Perez

:

  <pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">#!/bin/bash

# NAMESPACED EXPORTS
 for  ns in  $( kubectl get ns --no-headers | cut -d " "  -f1 ) ;  do
  kubectl --namespace = " ${ ns} "  get -o = json bindings,cm,ep,ev,limits,pvc,po,podtemplates,rc,quota,secrets,sa,svc,controllerrevisions,ds,deploy,rs,sts,localsubjectaccessreviews,hpa,cj,jobs,leases,ev,ds,deploy,ing,netpol,rs,pods,netpol,pdb,roles,rolebindings |  \
       jq '.items[] |
     select(.type!="kubernetes.io/service-account-token") |
     del(
         .spec.clusterIP,
         .metadata.uid,
         .metadata.selfLink,
         .metadata.resourceVersion,
         .metadata.creationTimestamp,
         .metadata.generation,
         .status,
         .spec.template.spec.securityContext,
         .spec.template.spec.dnsPolicy,
         .spec.template.spec.terminationGracePeriodSeconds,
         .spec.template.spec.restartPolicy
     )'  >> "./ ${ ns} .json"
 done

# NON-NAMESPACED EXPORTS
kubectl get -o = json cs,ns,no,pv,mutatingwebhookconfigurations,validatingwebhookconfigurations,crds,apiservices,tokenreviews,selfsubjectaccessreviews,selfsubjectrulesreviews,subjectaccessreviews,csr,psp,nodes,psp,clusterrolebindings,clusterroles,pc,sc,volumeattachments |  \
       jq '.items[] |
     select(.type!="kubernetes.io/service-account-token") |
     del(
         .spec.clusterIP,
         .metadata.uid,
         .metadata.selfLink,
         .metadata.resourceVersion,
         .metadata.creationTimestamp,
         .metadata.generation,
         .status,
         .spec.template.spec.securityContext,
         .spec.template.spec.dnsPolicy,
         .spec.template.spec.terminationGracePeriodSeconds,
         .spec.template.spec.restartPolicy
     )'  >> "./cluster_non-namespaced_export.json"

Script copied here under CC BY-SA 4.0 license

.

Related

Kubernetes not passing full path to Nodejs

·1 min
I spent hours troubleshooting why the url path was getting stripped from requests in our Nodejs/Expressjs based app. The reason was this line in Kubernetes’ Ingress: nginx.ingress.kubernetes.io/rewrite-target : / Removing it fixed the issue. Check the Kubernetes documentation for more details.

Ask HN: Software Engineer hitting 40: what's next?

·1 min
Recent thread on Hacker News, https://news.ycombinator.com/item?id=29360119, was very interesting for me especially since I turned 40 this year. Programming is something I enjoy and am pretty good at it. I’m still not at the top of the salary range for programmers but this is a tough question. I can get into FAANG but there is still a ceiling of how much one can earn as a software engineer. This comment says it best:

Wealth Lab Pro Earning Play Screener

·1 min
This is a quick script that I use to find options to buy or sell. using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { DataSeries maFast = EMAModern.Series(Close, 50 ); DataSeries maSlow = EMAModern.Series(Close, 200 ); DataSeries maFast_1 = EMAModern.Series(Close, 10 ); DataSeries maSlow_2 = EMAModern.Series(Close, 50 ); DataSeries ma = EMAModern.Series(Close, 10 ); DataSeries maFast_3 = EMAModern.Series(Close, 10 ); DataSeries maSlow_4 = EMAModern.Series(Close, 50 ); PlotSeries(PricePane,EMAModern.Series(Close, 50 ),Color.Red,LineStyle.Solid, 2 ); PlotSeries(PricePane,EMAModern.Series(Close, 200 ),Color.Green,LineStyle.Solid, 2 ); PlotSeries(PricePane,EMAModern.Series(Close, 10 ),Color.Blue,LineStyle.Solid, 2 ); PlotSeries(PricePane,EMAModern.Series(Close, 50 ),Color.Red,LineStyle.Solid, 2 ); PlotSeries(PricePane,EMAModern.Series(Close, 10 ),Color.Blue,LineStyle.Solid, 2 ); //for(int bar = GetTradingLoopStartBar(201); bar < Bars.Count; bar++) int bar = Bars.Count - 1 ; { if (IsLastPositionActive) { Position p = LastPosition; if (p.EntrySignal.Contains("Group1|" )) { if (CrossUnder(bar, maFast_3, maSlow_4)) { SellAtMarket(bar + 1 , p, "Group1" ); } } } else { if (maFast[bar] > maSlow[bar]) { if (maFast_1[bar] > maSlow_2[bar]) { if (Close[bar] < ma[bar]) { if (EarningsDate.InWindow( this , bar, "earnings per share" , 7 , 0 )) { BuyAtMarket(bar + 1 , "Group1|" ); } } } } } } } } }