# The command you find in MASTER NODE.
docker swarm join --token SWMTKN-1-1t1u0xijip6l33wdtt7jpq51blwx0hx3t54088xa4bxjy3yx42-90lf5b4nyyw4stbvcqyrde9sf MASTERNODEIP:2377
in node01:
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
m55wcdrkq0ckmtovuxwsjvgl1 * master01 Ready Active Leader 19.03.8
e9igg0l9tru83ygoys5qcpjv2 node01 Ready Active 19.03.8
git clone https://github.com/jaganthoutam/kong-konga-compose.git
cd kong-konga-compose
docker stack deploy --compose-file=docker-compose-swarm.yaml kong
#Check Services
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
ahucq8qru2xx kong_kong replicated 1/1 kong:1.4.3 *:8000-8001->8000-8001/tcp, *:8443->8443/tcp
bhf0tdd36isg kong_kong-database replicated 1/1 postgres:9.6.11-alpine
tij6peru7tb8 kong_kong-migration replicated 0/1 kong:1.4.3
n0gaj0l6jyac kong_konga replicated 1/1 pantsel/konga:latest *:1337->1337/tcp
83q1eybkhvvy kong_konga-database replicated 1/1 mongo:4.1.5
setup.ilm.enabled: false #Set ilm to False
setup.template.name: "k8s-dev" #Create Custom Template
setup.template.pattern: "k8s-dev-*" #Create Custom Template pattern
setup.template.settings:
index.number_of_shards: 1 #Set number_of_shards 1, ONLY if you have ONE NODE ES
index.number_of_replicas: 0#Set number_of_replicas 1, ONLY if you have ONE NODE ES
output.elasticsearch:
hosts: ['192.168.1.142:9200']
index: "k8s-dev-%{+yyyy.MM.dd}" #Set k8s-dev-2020.01.01 as Index name
alias dm=’docker-machine’
alias dmx=’docker-machine ssh’
alias dk=’docker’
alias dki=’docker images’
alias dks=’docker service’
alias dkrm=’docker rm’
alias dkl=’docker logs’
alias dklf=’docker logs -f’
alias dkflush=’docker rm `docker ps –no-trunc -aq`’
alias dkflush2=’docker rmi $(docker images –filter “dangling=true” -q –no-trunc)’
alias dkt=’docker stats –format “table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}”‘
alias dkps=”docker ps –format ‘{{.ID}} ~ {{.Names}} ~ {{.Status}} ~ {{.Image}}'”
How cool it is to run the kubectlcommands from slack channel… 🙂 This is not fully developed yet, but it comes in handy with dev, staging ENV. Let’s Begin.
Requirements: 1. create a new slack bot 2. Create Slack Channel(not private), and get the channel ID. https://slack.com/api/channels.list?token=REPLACE_TOKEN&pretty=1 to get the Channel ID here. 3. Add Slack-bot to the channel you created. 4. Then use the below file to create K8s Deployment.
---
#create servuce account
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubebot-user
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubebot-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
# Create ClusterRole with Ref NOTE : clsuter-admin is more powerful
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubebot-user
namespace: default
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kubebot
labels:
component: kubebot
spec:
replicas: 1
template:
metadata:
labels:
component: kubebot
spec:
serviceAccountName: kubebot-user
containers:
- name: kubebot
image: harbur/kubebot:0.1.0
imagePullPolicy: Always
env:
# Create a secret with your slack bot token and reference it here
- name: KUBEBOT_SLACK_TOKEN
value: TOKENID_THAT_WAS CREATED
# Alternatively, use this instead if you don't need to put channel ids in a secret; use a space as a separator
# You get this from https://slack.com/api/channels.list?token=REPLACE_TOKEN&pretty=1
- name: KUBEBOT_SLACK_CHANNELS_IDS
value: 'AABBCCDD'
# Specify slack admins that kubebot should listen to; use a space as a separator
- name: KUBEBOT_SLACK_ADMINS_NICKNAMES
value: 'jag test someone'
# Specify valid kubectl commands that kubebot should support; use a space as a separator
- name: KUBEBOT_SLACK_VALID_COMMANDS
value: "get describe logs explain"