Upgrade your browser experience

Microsoft Edge/Opera/Google Chrome has become the de-facto browser for internet. This suite here will greatly further enhance your browsing experience:

Tab & URL manager

Problem statement:

we tend to have so many tabs open, it becomes difficult to find the specific tabs among so many we have opened.

Instead, we normally tend to just open a new tab which has already been open and hidden somewhere, this will additionally consume more of our computer memory usage.

We have visited certain pages before, but really cannot recall the complete address of the page.

We are trying to search for a term, however, would like to see only the top suggestions.

We might have different search engines would like to leverage on, for example maybe bing for desktop images, or baidu for chinese languages.

We have a limited screen, would like to maximize the space screen, instead of leaving the address and tab to consume the precious screen space.

Solution:

Install the Tab & URL manager here, 
https://chrome.google.com/webstore/detail/tab-url-manager/egiemoacchfofdhhlfhkdcacgaopncmi

Use the shortcut to open the Tab & URL manager
Windows: Alt+L

Mac: ⌥+L

In addition, you can configure further keyword mapping in the Extension Options.
* type a URL followed by enter to visit the specified address
* type a term followed by enter to search the term (the search engine is configurable)
* type a term to navigate to any popular search suggestions
* type a keyword to navigate to any mapped URL (the map is configurable)
* type a term to navigate to any open tabs
* type a term to get the likely result you would like to visit

ShortCut for URL mapper

Problem Statement:

It’s always difficult to remember the long URLs. Yet, we could have so many pages we normally visit.

Solution:

Install the ShortCut for URL mapper here, 

https://chrome.google.com/webstore/detail/short-cut-for-url-mapper/lafchflokhmpcoaondfeffplkdnoaelh

Click the extension, to configure the keyword to URL mappings.

After that, just type sc in the address bar, followed by the keyword would bring you to the targeted page.

My Tabs

Problem Statement:

We all have list of often visited pages each. Normally we would either bookmark them, then click one by one to open each, or just open a new tab each and type the URLs manually.

This is very tedious and waste our precious time.

Solution:

Install MyTabs here
https://chrome.google.com/webstore/detail/mytabs/mjapfgokeoeigopkkjnlkhgpcgoaoenf
Click the extension, to configure the often visited pages.

Then each time auto load them all with one click Alt+Shift+T, or if using Mac, Option+Shift+T.

Datadog APM tracing and logging

Recently, I have set up my micro services application onto datadog APM with tracing and logging.

something like,


so that we can follow through, for example, any http request or user_id from HTTP request, controller, service, authentication, database, and etc, with the same tracing ID and logs detailed.

Here are the steps I have followed:

  1. Set up datadog account and access, so that we will get the datadog API key, which is to be used to upload the data to datadog server
  2. install the datadog agent onto the server, we are using kubernetes on AWS (EKS) here, and have installed it as a daemonset (so that we have one for each node) with terraform.

set up the necessary environment variable in the daemonset

and expose the necessary ports

3. from the python services, leverage on libraries, for example, https://pypi.org/project/JSON-log-formatter/0.1.0/, to log the messages into JSON format

format = "%(asctime)s %(levelname)s [%(name)s]-- '[dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] ' -- %(message)s"
json = jsonlogger.JsonFormatter(format)

handler = logging.StreamHandler()
handler.setFormatter(json)

so that these logs would be in JSON format, and datadog would be able to parse the logs into tags & attributes.

4. then configure the datadog tracing


from ddtrace import config, patch_all, tracer


def setup_datadog():
    tracer.configure(
        hostname=os.environ["DD_AGENT_HOST"],#set up in the deployment.yaml, the env attribute
    )
    tracer.set_tags({"env": "production"})
    config.flask["service_name"] = "checkout-service" #this could also set up in the deployment.yaml, the env attribute
    config.flask["analytics_enabled"] = True
    config.flask["extra_error_codes"] = [401, 403]
    patch_all()

5. finally, then annotate the entry point function, with

@tracer.wrap(service="checkout-service")

sample configuration in the deployment.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
...
  annotations:
    ad.datadoghq.com/checkout.logs: '[{"source":"python", "service": "checkout-service"}]'
spec:
  replicas: 1
...
  template:
    metadata:
    spec:
      containers:
      -  name: checkout
...
        env:
          - name: DD_AGENT_HOST
            valueFrom:
              fieldRef:
                fieldPath: status.hostIP
          - name: DD_SERVICE
            value: checkout-service
          - name: DD_TRACE_ANALYTICS_ENABLED
            value: "true"
...
      restartPolicy: Always
status: {}

Persistence Volume Stuck at terminating

Sometimes, PV and PVC could stuck at terminating. This is because there is a finalizer to protect the PV and PVC termination while there are still possible usage.

For example, when I am trying to delete the PV

both PV and PVC however are stuck for quite a while

the resolution is to edit and remove the finalizers:

then without the finalizers, it will let the PV and PVC termination.

kubernetes endpoints

endpoints is normally used behind the scene, without the need of any manual intervention.

However, for local testing, it could become helpful to leverage on the endpoints customization.

---	
  kind: "Service"
  apiVersion: "v1"
  metadata:
    name: "svc-to-external-web"
  spec:
    ports:
      - name: "apache"
        protocol: "TCP"
        port: 80
        targetPort: 80 
---
  kind: "Endpoints"
  apiVersion: "v1"
  metadata:
    name: "svc-to-external-web" 
  subsets: 
    - addresses:
        - ip: "8.8.8.8" #The IP Address of the external web server
        ports:
        - port: 80 
          name: "apache"

for example, with above, if we create a service without any selector (of any pods/deployments), and manually create an endpoint with the same name as the service, then we can configure where the endpoint point to, which could be an external IP address, or maybe to a docker service

like

apiVersion: v1
kind: Endpoints
metadata:
  name: svc-to-external-web
subsets:
- addresses:
  - ip: 192.168.64.1 # minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }'"
  ports:
  - port: 80

ref: https://theithollow.com/2019/02/04/kubernetes-endpoints/

pod stuck at pending with custom scheduler

i have created a custom scheduler, which has been in running state.

however, when i create a new pod, assigning it to the custom scheduler, through .spec.schedulerName. the pod has been stuck in pending state.


here are the sample configuration

scheduler.yml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-scheduler
    tier: control-plane
  name: my-scheduler
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-scheduler
    - --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
    - --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
    - --bind-address=127.0.0.1
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=true
    - --port=10351
    - --scheduler-nam=my-scheduler
    - --secure-port=10359
    image: k8s.gcr.io/kube-scheduler:v1.16.0
    imagePullPolicy: IfNotPresent

pod.yml

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  schedulerName: my-scheduler
  containers:
  -  image: nginx
     name: nginx

turns out the issue was with the --leader-elect. seems like the scheduler is not able to move forward with the --leader-elect set to true.

error running etcd in minikube

when I am trying to run etcdctl in minikube, there has been an exception:

commands:

ETCDCTL_API=3 etcdctl get "" --prefix=true
ETCDCTL_API=3 etcdctl get "" --from-key

Exception

{"level":"warn","ts":"2020-05-01T09:32:07.933Z","caller":"clientv3/retry_interceptor.go:61","msg":"retrying of unary invoker failed","target":"endpoint://client-ea0c78af-0a9d-4092-8722-75fed707e112/127.0.0.1:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest connection error: connection closed"}
Error: context deadline exceeded

the solution is to provide the needed ca files

ETCDCTL_API=3 etcdctl get "" --prefix=true --cacert=/var/lib/minikube/certs/etcd/ca.crt --cert=/var/lib/minikube/certs/etcd/server.crt --key=/var/lib/minikube/certs/etcd/server.key

the cert can be found by running

kubectl get pod etcd-minikube -n kube-system -o yaml