Extract sub-array from an array in javascript
You can use the slice() method in JavaScript to get a sub-array from an array. Here’s a simple example: In this example, the slice() method takes two arguments: the start index and the end index. The start index is inclusive, and the end index is exclusive. So array.slice(3, 7) returns a new array starting from the 4th element (index 3)…
Configure Git Proxy With Socks5
To configure Git to use a SOCKS proxy, you use the http.proxy and https.proxy configuration options. Here is how you can do it: In this command, 127.0.0.1 is the local IP address and 1080 is the port number. Replace these with your SOCKS proxy’s IP address and port number. Again, replace 127.0.0.1 and 1080 with your SOCKS proxy’s IP address…
Setup ngx-translate in angular
In angular typescript, we can use ngx-translate for i18n, and ngx-translate-extract for extracting keys to generate multiple language file. i will describe how to setup i18n in angular with ngx-translte, and how to extract messages with ngx-translate-extract. To setup ngx-translate, run the following command: in app.module, add module import for whole app usage, in app constructor function, setup default language…
Configure Monaco Editor Language and Theme in Angular Typescript
In angular typescript environment, the vscode editor is integrated by ngx-monaco-editor, for how to install ngx-monaco-editor on angular typescript environment, refer to previous article intergrate-vscode-editor-in-angular When ngx-nonaco-editor is ready, update your html file, add onInit() callback when initlalizing it, In onInit() function, save the instance, Add on language change or theme change event call function
Install and Setup Docker On CentOS Stream 8
Install and Setup Docker On CentOS Stream 8, the docker repo should be installed first, and then install it by yum, the default centos does not distribute docker packages. Set up the repository Install the yum-utils package (which provides the yum-config-manager utility) and set up the repository. Install Docker Engine Install Specific version To install a specific version, start by listing the available versions…
Intergrate vscode editor in angular
To intergrate vscode editor in angular 13 typescript and above, ngx monaco editor should be installed. The following steps described how to install and setup it. 1, Install ngx-monaco-editor js packages 2, Add the glob to assets in angular.json schema – projects.[project-name].architect.build (to make monaco-editor lib available to the app): 3, In app.module or your sub-module ts file, and editor config, define NgxMonacoEditorConfig 4,…
Spring WebFlux Databuffer Limit
The default databuffer limit size in spring webflux is 262144(256K) bytes, and it is hardcode in Base class(BaseDefaultCodecs), When you calling webclient with large data reponsed, an DataBufferLimitException exceptoin will throw and the following error will occured: To solve this problem or configure the data buffer limit, try the following methods: using ExchangeStrategies to set webclient codecs parameter. configure in…
Understanding sync.Map in Go
As we know that go provides a type of map that allows us to store key-value pair data, but if we use map in a concurrent situation, we will find that it does not support concurrent reading and writing (an error will be occured).In this case, we can use sync.Mutex to ensure concurrency safety, but this will cause us to…
Kubernetes configmap guide
A ConfigMap is a Kubernetes resource that allows you to store configuration data as key-value pairs. You can use ConfigMaps to separate configuration data from your application code and enable configuration updates without the need for a full application restart. When used, Pods can use it as an environment variable, as a command-line argument, or as a configuration file in…
Happy New Year
Happy New Year! The Chinese new year is comming soon(The day after tomorrow). Wish you all who comes here: The next year is better than this year, and is worse than the year after next year!
Php configure memcached in centos8
Install and configure php and memcached plugin for wordpress setup on centos8 I use pecl to manually install memcached plugin. For how to install php and pecl environment on centos8/rhel8, refer to previous post. how to install php 7.4 on centos 8 Install memcached on centos8/rhel8 Configure memcached Enable and start memcached When php and memcache environment is ready, Run…
Kubernetes Pod Resource Usage Checking
There are so many ways to check pod resource usage such as cpu and memory in kubernetes, kubectl top command or quering from prometheus. In this article, i will describe these two methods to check pod resource usage in kubernetes environment. Table of Contents Using kubectl top command Querying metrics from prometheus Using kubectl top command beforing running this command,…
Kubernetes copy file from pod to local
Kubernetes client kubectl provides cp sub command to copy file from pod to local filesystem or from local filesystem to pod. You can use the kubectl cp command to copy files from a pod to your local system.The syntax for the command is as follows: For example, if you have a pod named “my-pod” in the “my-namespace” namespace and you…
Troubleshooting kubernetes pod get stuck in Terminating status
Pods in Kubernetes can sometimes get stuck in the “Terminating” status, which means that they are being terminated but have not yet completed the process. This can happen for several reasons: Containers inside the pod are not terminating If a container inside the pod is not terminating, it can prevent the pod from being terminated. You can use the command…
Kubernetes secret decode
In Kubernetes, a secret is a way to store sensitive information, such as passwords, tokens, or keys, that can be used by pods or services running in the cluster. Secrets are stored in a base64-encoded format, which provides some level of security, but they can be decoded and viewed by anyone with access to the cluster. Secrets can be created,…
Re-run A Kubernetes Scheduled Job manually
A Kubernetes Scheduled Job is designed to run automatically based on a schedule defined in the cron format. However, there are a few ways to trigger a Scheduled Job manually. Edit the schedule You can edit the schedule in the Job’s YAML file and set it to run immediately. Once you have made the change, you can apply it by…
Kubernetes Image update/pull policy
In Kubernetes, the image pull policy is a configuration option that determines how the system should handle pulling container images. There are three possible values for the image pull policy: Always: The system will always pull the latest version of the image, regardless of whether or not an image with the same tag is already present in the local cache.…
Add External Image Registry in OpenShift
There are serval ways to connect an external image registry (such as harbor) to your openshift environments. In installation phase, you can add image registry in installation-config.yaml, and set credentials in pull-secret. When your cluster is up and running, update cluster config to trust an external image registry. This article will describe how to setup harbor and add it to…
Run multiple commands in kubernetes
This article will describe how to run multiple commands on container startup phase in kubernetes. Kubernetes provides several ways to run multiple command for a container, such as command parameter in container spec, or provide an entry point shell. bellow is an example for demonstrate how to run multiple commands in kubernetes. Using command parameter Also, you can use command…
OpenShift 4 Internal Image Registry Configuration
By default, when you install your openshift 4 cluster on bare metal manually, the internal image registry is not available, and the imagestream, buildconfigs may not working as you want, if you deploy a pod from the default template, the following error occured: The image-registry.openshift-image-registry.svc is a cluster internal svc name, this domain is configured by dns-node-resolver Daemonset to add…
Keep Container Running On Kubernetes
When you trying to run a simple container with shell (/bin/bash) on a Kubernetes cluster, the container exits when its main process exits. you will see your pod in completed state. To keep your pod/container always running on kubernetes, you need to provide your container a task that will never finish. There are several ways to accomplish that. Table of…
Setup NFS storage class in OpenShift 4
NFS storageclass is an easy to use storage option for kubernetes and openshift platform. I will describe how to setup a nfs server, and deploy and setup nfs storage class in openshift 4 environment. Table of Contents Deploy nfs server Deploy nfs storage provisioner Deploy nfs server Install and setup nfs server service on centos stream 8. selinux and firewalld…
OpenShift 4.10 high available cluster installation Tutorial
In this tutorial, i will describe how to install and setup an openshift container platform (OCP) 4.10 cluster with high available architecture manually. This is a step by step guide for installing an OpenShift 4 cluster with high availability, and i will try my best to describe it as clearly as i can. This installation will use connected network to…
Nginx setup and configuration guide
Nginx is a complex and rubust software, for this guide, we only care about how to setup it for layer7 and layer4 configuration. This guide instroduce configuration for webserver(layer7) and load balancer(layer4), and is based on centos8 stream os, we do not cover performence tuned here. Table of Contents What’s nginx? Nginx installation on centos stream 8/9 Configure for webserver…