關於網路那些事...

Marketing, SEO, Web trends, Programming tutorial, Web design, and Life event...

Getting start to run kubernetes

This article will illustrate how to run a Kubernetes in mac M1 local, and learn how to use kubectl command to deploy a service. More detailed concept can reference Kubernetes documents

Continue Reading

Deploy a Go Project to Docker hub by Github Action

In this article, we will create a simple golang application CI/CD process and push it to Docker hub by github action. Finally, will illustrate an example of how to use the terraform and docker-compose to deploy a local docker environment.

Create Docker hub repository

First, create a repository on Docker hub, here we create a repo name adon988/go-github-action-helloworld

Generate Github Actions workflow

Create a project folder .github/workflows/ and add github actions yaml file

Continue Reading

Golang: Gin + Gorilla to build a websocket application

Here we used the gorilla module to build a websocket application, and this tutorial will focus on building up a websoccket server.

About client part will implement with the chrome extension: Websocket King.

Get gorilla module

go get github.com/gorilla/websocket

Build a websocket server

Following are examples of simple websocket servers built with gin and gorilla,

Gin creates a get request and upgrades this HTTP connection to websocket connection by upgrader.Upgrade.

Continue Reading

Golang: 解決 Go Websocket upgrade:websocket: request origin not allowed by Upgrader.CheckOrigin 跨域問題

Golang: 解決 Go Websocket upgrade:websocket: request origin not allowed by Upgrader.CheckOrigin 跨域問題

錯誤訊息:

upgrade:websocket: request origin not allowed by Upgrader.CheckOrigin

原因: 如內文所述,在 Go Websocket 判別跨域來源不合法

解決方式: 需要在 websocket.Upgrader 設定 CheckOrigin 來源,例如下方允許所有來源

var upgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool {
		return true
	},
} // use default options

例如,在使用 Chrome Websocket King Client 擴充時,可以只允許這個來源,例如:

var upgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool {
		origin := r.Header.Get("Origin")
		return origin == "chrome-extension://cbcbkhdmedgianpaifchdaddpnmgnknn"
	},
}

Continue Reading

使用 Aws Copilot CLI 部署 AWS ECS

AWS Copilot CLI 是一個開源的 CLI ,可以方便地用於管理 AWS App Runner, AWS ECS, AWS Farget.

只要透過簡單的指令就可搭建起 containerized application,

在本文會先介紹 ECS 以及如何透過 Copilot 來部署應用到 ECS 。

AWS ECS 簡介

AWS ECS(Elastic Container Service) 是一個簡單且高擴充的 container cluster 管理服務, 可以透過 task definnition 定義 container 並且直接運行在 serverless infrastructure (Fargate),或者可以選用 EC2 來做更多的調控。

下方是一個 ECS Object 示意

在開始創建 ECS ,有以下流程

Container definition : 會先需要選擇 image 以及規格 (cpu, RAM….)

Task definition : 用於定義 APP 的藍圖,可以用來描述要部署的一個或多個 containers (最多10 個) ,透過 attributes 設定 container 配置(network, cpu, ram..) 等

Continue Reading

Elasticsearch Cluster shards and replicas 常見問題

這邊列出幾個常見的 shards & replicas 問題及流程機制:

Continue Reading

Linux 安裝及配置 Elasticsearch cluster

本文紀錄 Linux 安裝及配置 Elasticsearch 單節點以及 cluster 流程:

Continue Reading

Elasticsearch 常見索引操作彙整

這裡記錄一些 Elasticsearch 常用的索引操作方式,方便之後查詢參考

Continue Reading

Elasticsearch 核心概念及機制說明

這裡記錄一些 Elasticsearch 核心概念及機制說明:

Continue Reading

Getting Started With Tmux

Tmux install and quickly start

Tmux is a terminal multiplexer that can run multiple programs in one terminal. There is powerful to manage several programs in the remote server in one terminal, and using the session to attach or detach them. A prefix is an advanced tool that supports split windows and quick short keys.

That’s getting the start for how to using tmux. Here will showing common usage about tmux.

Continue Reading

What Is Sli Slo Sla and User Facing

A service provider probably has a technology-related service contract with the client to promise about the service level availability and usability.

Here we will discuss service level terminology about SLI/SLO/SLA and User-Facing:

Continue Reading

How to setting mysql long query log to recording slow query

How to setting mysql long query log to recording slow query

Database slow query is a normalized case in operation situation. For example, if a new feature in production has a long data loading time, we can check this situation in the application log or database slow query.

Here, is how to set MySql slow query log.

Continue Reading

Saltstack introduction - How to install salt master and salt minion

Saltstack is an automatic configuration management tool, easy extension infrastructure, and high performance.

Using Saltstack can easy to manage large-scale servers, include dynamic connections, can be used for remote/local execution, config management, etc.

Continue Reading

Flutter - How to solve VSCode not show iOS simulator device

When running Xcode and iOS simulator, open VSCode does not show the iOS device but has Android emulator options.

How to show iOS simulator in VSCode?

Continue Reading

Flutter - How to solve the error of Unable to load asset for local images

Why unable to load asset for local images and how to load local images

How to solve the problem of “another exception was thrown: Unable to load asset:” in flutter?

Here is the step for flutter how to load local images:

First, for use asset image in local, image location should be add in pubsec.yaml

Continue Reading

Getting start with Dart before Flutter

Flutter tutorial: Getting start with Dart

Dart is created by Google in 2011, and can be use for web, server, mobile, and IoT, also can be use to develop Flutter.

Here we will present a quickly short guid for let you understand what is Dart and how to use it. For more detail about Dart can reference tour of basic Dart program.

Continue Reading

Install flutter in mac and build first project

This tutorial will demonstrate how to install flutter in Mac and build the first app with Xcode.

To install flutter and develop the app, we need to check environment meet minimum requirements

  • Disk space: 2.8 G
  • macOS 64-bit
  • Xcode

Continue Reading

How to customerize the Live Sass Compiler settings for CSS output path and formats

In Visual Studio Code, I’m using the Live Sass Compiler and Live Server (both plugins are developed by Ritwick Dey) for the development HTML project.

After install Live Sass compiler and Liver Server, the quickly functional button “Watch Sass” and “Go Live” will show in the VSCode bottom status list.

Continue Reading

How download videos or live streaming from Azure Media Service content

Here is a tutorial for download video or streaming from Azure Media Service content.

Azure Media Player provides one player to support multiple devices and formate and integration content protection.

Azure media service is provided a stream solution with Azure Media Player, Azure media service is using manifest as streaming info contains the file.

When we need to download content from Azure media, first, we need to get the manifest URL,

Continue Reading

Golang - Using Cobra to build your CLI Application

Cobra is a golang library for creating CLI applications and is using by Kubernetes, Hugo, and Github CLI..

Here we will show how to use cobra to build a CLI app.

Continue Reading