Skip to content

Instantly share code, notes, and snippets.

View selcukusta's full-sized avatar

Selçuk Usta selcukusta

View GitHub Profile
function formatBytes(bytes, decimals = 2) {
if (!+bytes) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: get-python-hpa
namespace: kubeless-fn
labels:
function: get-python
spec:
scaleTargetRef:
apiVersion: apps/v1
{
"kind": "MetricValueList",
"apiVersion": "custom.metrics.k8s.io/v1beta1",
"metadata": {
"selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/kubeless-fn/pods/%2A/calls_total_per_minute"
},
"items": [
{
"describedObject": {
"kind": "Pod",
helm template --name kubeless-adapter charts/stable/prometheus-adapter \
--set prometheus.url=http://prometheus-service.monitoring.svc \
--set prometheus.port=9090 \
--set metricsRelistInterval=30s \
--set rules.default=false \
--set-file rules.custom=custom-rules.yaml > 1-install-prometheus-adapter.yaml
- seriesQuery: '{__name__=~"function_.*",kubernetes_namespace="kubeless-fn",function!="",kubernetes_pod_name!=""}'
resources:
overrides:
kubernetes_namespace: { resource: "namespace" }
kubernetes_pod_name: { resource: "pod" }
name:
matches: "^function_(.*)"
as: "${1}_per_minute"
metricsQuery: sum(increase(<<.Series>>{<<.LabelMatchers>>}[1m]))
by (<<.GroupBy>>)
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: sample-lua
namespace: default
spec:
workloadSelector:
labels:
app: sample-app
configPatches:
  1. Aşağıdaki kod bloğu ile CSR (Certificate Signing Request) dosyası ve key dosyası oluşturulur. NOT: .key uzantılı dosya dışarıya sızdırılmamalıdır!
openssl req -new -newkey rsa:2048 -nodes -keyout www_yourdomain_com.key -out www_yourdomain_com.csr
  1. .csr uzantılı dosya sertifika temin edilecek firmaya iletilir ve içeriği aşağıdakine benzer - ya da aşağıdaki ile aynı - .zip uzantılı dosya edinilir.
! PRIVATE KEY INFO !.txt
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: app-vs
spec:
hosts:
- "selcukusta.com"
- "www.selcukusta.com"
gateways:
- app-gw
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: app-gw
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- "selcukusta.com"
currentConfigMap := &corev1.ConfigMap{}
newConfigMap := r.createConfigMap(instance, map[string]string{instance.Spec.Config.ConfigMapKey: instance.Spec.Config.ConfigMapValue})
err = r.client.Get(context.TODO(), types.NamespacedName{Name: instance.Spec.Config.ConfigMapName, Namespace: request.Namespace}, currentConfigMap)
if err == nil {
if !reflect.DeepEqual(currentConfigMap.Data, newConfigMap.Data) {
reqLogger.Info(fmt.Sprintf("ConfigMap will be changed: %v", instance.Spec.Config.ConfigMapName))
if r.client.Update(context.TODO(), newConfigMap) != nil {
return reconcile.Result{}, err
}