Skip to content

Commit 93fedea

Browse files
committed
init
0 parents  commit 93fedea

File tree

8 files changed

+211
-0
lines changed

8 files changed

+211
-0
lines changed

.github/workflows/release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release Binaries
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
push_to_registry:
9+
name: Build Binary
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out the repo
13+
uses: actions/checkout@v4
14+
15+
- name: Install Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: "^1.22"
19+
20+
- name: Backend Dependecy Install
21+
run: go mod download
22+
working-directory: ./
23+
24+
- name: Log in to Mono Registry
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.REGISTRY_USER }}
28+
password: ${{ secrets.REGISTRY_PASS }}
29+
30+
- name: Push to Mono Registry
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: ./
34+
file: ./Dockerfile
35+
push: true
36+
tags: |
37+
kintsdev/test-kube:latest
38+

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
go.work.sum

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM golang:1.22-alpine AS builder
2+
3+
RUN apk add --no-cache upx
4+
RUN apk --no-cache add tzdata
5+
6+
WORKDIR /src/go
7+
8+
COPY . .
9+
10+
RUN go mod download
11+
12+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o test-kube main.go
13+
RUN upx test-kube
14+
15+
16+
FROM scratch
17+
18+
19+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
20+
21+
WORKDIR /bin/kints
22+
23+
COPY --from=builder /src/go/test-kube .
24+
25+
26+
CMD [ "./test-kube" ]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 MonoPayments
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# test-kube

deployment.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: test-kube
5+
spec:
6+
replicas: 5
7+
selector:
8+
matchLabels:
9+
app: test-kube
10+
template:
11+
metadata:
12+
labels:
13+
app: test-kube
14+
spec:
15+
containers:
16+
- name: test-kube
17+
image: kintsdev/test-kube:latest
18+
env:
19+
- name: POD_NAME
20+
valueFrom:
21+
fieldRef:
22+
fieldPath: metadata.name
23+
- name: POD_NAMESPACE
24+
valueFrom:
25+
fieldRef:
26+
fieldPath: metadata.namespace
27+
- name: NODE_NAME
28+
valueFrom:
29+
fieldRef:
30+
fieldPath: spec.nodeName
31+
- name: HOST_IP
32+
valueFrom:
33+
fieldRef:
34+
fieldPath: status.hostIP
35+
- name: POD_IP
36+
valueFrom:
37+
fieldRef:
38+
fieldPath: status.podIP
39+
ports:
40+
- containerPort: 8080
41+
---
42+
apiVersion: v1
43+
kind: Service
44+
metadata:
45+
name: test-kube
46+
spec:
47+
type: ClusterIP
48+
selector:
49+
app: test-kube
50+
ports:
51+
- port: 8080
52+
targetPort: 8080
53+
---
54+
# ingress
55+
apiVersion: networking.k8s.io/v1
56+
kind: Ingress
57+
metadata:
58+
name: test-kube
59+
annotations:
60+
nginx.ingress.kubernetes.io/rewrite-target: /
61+
spec:
62+
rules:
63+
- host: test-kube.local
64+
http:
65+
paths:
66+
- path: /
67+
pathType: Prefix
68+
backend:
69+
service:
70+
name: test-kube
71+
port:
72+
number: 8080

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/kintsdev/test-kube
2+
3+
go 1.22.5

main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"os"
6+
)
7+
8+
var (
9+
podName string = os.Getenv("POD_NAME")
10+
namespace string = os.Getenv("POD_NAMESPACE")
11+
nodeName string = os.Getenv("NODE_NAME")
12+
hostIP string = os.Getenv("HOST_IP")
13+
podIP string = os.Getenv("POD_IP")
14+
)
15+
16+
func main() {
17+
// http server start 8080
18+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
19+
w.Write([]byte("Welcome to K8s\n"))
20+
w.Write([]byte("Pod Name: " + podName + "\n"))
21+
w.Write([]byte("Namespace: " + namespace + "\n"))
22+
w.Write([]byte("Node Name: " + nodeName + "\n"))
23+
w.Write([]byte("Host IP: " + hostIP + "\n"))
24+
w.Write([]byte("Pod IP: " + podIP + "\n"))
25+
})
26+
27+
http.ListenAndServe(":8080", nil)
28+
}

0 commit comments

Comments
 (0)