Skip to content

Commit

Permalink
Change the name 'tty-exporter' to 'local-session-tracker'
Browse files Browse the repository at this point in the history
  • Loading branch information
zoetrope committed Sep 17, 2024
1 parent 8385e50 commit 148ad1f
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ jobs:
push: true
tags: ghcr.io/cybozu-go/login-protector:${{ inputs.tag }},ghcr.io/cybozu-go/login-protector:latest
target: login-protector
- name: Build and Push tty-exporter
- name: Build and Push local-session-tracker
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/cybozu-go/tty-exporter:${{ inputs.tag }},ghcr.io/cybozu-go/tty-exporter:latest
target: tty-exporter
tags: ghcr.io/cybozu-go/local-session-tracker:${{ inputs.tag }},ghcr.io/cybozu-go/local-session-tracker:latest
target: local-session-tracker
- name: Setup Git Config
run: |
git config --global user.name github-actions
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ COPY internal/ internal/

RUN CGO_ENABLED=0 go install -ldflags="-w -s" ./cmd/...

# Build the tty-exporter binary
FROM scratch AS tty-exporter
# Build the local-session-tracker binary
FROM scratch AS local-session-tracker
LABEL org.opencontainers.image.source="https://github.com/cybozu-go/login-protector"

COPY --from=build /go/bin/tty-exporter .
COPY --from=build /go/bin/local-session-tracker .
USER 10000:10000
ENTRYPOINT ["/tty-exporter"]
ENTRYPOINT ["/local-session-tracker"]

# Build the login-protector binary
FROM scratch AS login-protector
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Image URL to use all building/pushing image targets
PROTECTOR_IMG ?= login-protector:dev
EXPORTER_IMG ?= tty-exporter:dev
TRACKER_IMG ?= local-session-tracker:dev

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -83,17 +83,17 @@ run: manifests fmt vet ## Run a controller from your host.
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${PROTECTOR_IMG} . --target=login-protector
$(CONTAINER_TOOL) build -t ${EXPORTER_IMG} . --target=tty-exporter
$(CONTAINER_TOOL) build -t ${TRACKER_IMG} . --target=local-session-tracker

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${PROTECTOR_IMG}
$(CONTAINER_TOOL) push ${EXPORTER_IMG}
$(CONTAINER_TOOL) push ${TRACKER_IMG}

.PHONY: load-image
load-image: docker-build setup
kind load docker-image ${PROTECTOR_IMG}
kind load docker-image ${EXPORTER_IMG}
kind load docker-image ${TRACKER_IMG}


.PHONY: build-installer
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl -fsL https://github.com/cybozu-go/login-protector/releases/latest/download/
login-protector targets only StatefulSets. The StatefulSet should be configured as follows:

1. Add the label `login-protector.cybozu.io/protect: "true"` to the StatefulSet.
2. Add the sidecar container `ghcr.io/cybozu-go/tty-exporter` and specify `shareProcessNamespace: true`.
2. Add the sidecar container `ghcr.io/cybozu-go/local-session-tracker` and specify `shareProcessNamespace: true`.
3. Set the `updateStrategy` to `type: OnDelete`.


Expand Down Expand Up @@ -71,8 +71,8 @@ spec:
image: ghcr.io/cybozu/ubuntu:22.04
imagePullPolicy: IfNotPresent
command: [ "sleep", "infinity" ]
- name: tty-exporter
image: ghcr.io/cybozu-go/tty-exporter:latest
- name: local-session-tracker
image: ghcr.io/cybozu-go/local-session-tracker:latest
imagePullPolicy: IfNotPresent
ports:
- name: sidecar
Expand All @@ -86,8 +86,8 @@ spec:
Annotations can be used to modify the behavior of login-protector for the target StatefulSet:
- `login-protector.cybozu.io/exporter-name`: Specify the name of the tty-exporter sidecar container. Default is "tty-exporter".
- `login-protector.cybozu.io/exporter-port`: Specify the port of the tty-exporter sidecar container. Default is "8080".
- `login-protector.cybozu.io/exporter-name`: Specify the name of the local-session-tracker sidecar container. Default is "local-session-tracker".
- `login-protector.cybozu.io/exporter-port`: Specify the port of the local-session-tracker sidecar container. Default is "8080".
- `login-protector.cybozu.io/no-pdb`: Set to "true" to prevent the creation of a PodDisruptionBudget.


Expand Down Expand Up @@ -119,7 +119,7 @@ spec:
imagePullPolicy: IfNotPresent
command: [ "sleep", "infinity" ]
- name: sidecar
image: ghcr.io/cybozu-go/tty-exporter:latest
image: ghcr.io/cybozu-go/local-session-tracker:latest
imagePullPolicy: IfNotPresent
ports:
- name: sidecar
Expand Down
12 changes: 6 additions & 6 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ CMD ["/login-protector"]

EXPORTER_DOCKERFILE = '''FROM golang:alpine
WORKDIR /
COPY ./bin/tty-exporter /
CMD ["/tty-exporter"]
COPY ./bin/local-session-tracker /
CMD ["/local-session-tracker"]
'''

# Generate manifests
Expand Down Expand Up @@ -39,11 +39,11 @@ docker_build_with_restart(
k8s_yaml("./test/testdata/statefulset.yaml")

docker_build_with_restart(
'tty-exporter:dev', '.',
'local-session-tracker:dev', '.',
dockerfile_contents=EXPORTER_DOCKERFILE,
entrypoint=['/tty-exporter', '--zap-devel=true'],
only=['./bin/tty-exporter'],
entrypoint=['/local-session-tracker', '--zap-devel=true'],
only=['./bin/local-session-tracker'],
live_update=[
sync('./bin/tty-exporter', '/tty-exporter'),
sync('./bin/local-session-tracker', '/local-session-tracker'),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"syscall"

"github.com/cybozu-go/login-protector/internal/common"
tty_exporter "github.com/cybozu-go/login-protector/internal/tty-exporter"
local_session_tracker "github.com/cybozu-go/login-protector/internal/local-session-tracker"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
)
Expand All @@ -30,7 +30,7 @@ func main() {
defer logger.Sync() //nolint:errcheck
logger.Info("starting ttypdb-sidecar...")

tty_exporter.InitMetrics(logger)
local_session_tracker.InitMetrics(logger)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -52,7 +52,7 @@ func main() {
mux := http.NewServeMux()
mux.HandleFunc("/readyz", handleReadyz)
mux.Handle("/metrics", promhttp.Handler())
mux.Handle("/status", tty_exporter.NewStatusHandler(logger))
mux.Handle("/status", local_session_tracker.NewStatusHandler(logger))
server := http.Server{
Addr: fmt.Sprintf(":%d", httpServerPort),
Handler: common.NewProxyHTTPHandler(mux, logger),
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/pdb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *PDBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
return ctrl.Result{}, err
}

exporterName := "tty-exporter"
exporterName := "local-session-tracker"
if name, ok := sts.Annotations[common.AnnotationKeyExporterName]; ok {
exporterName = name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tty_exporter
package local_session_tracker

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tty_exporter
package local_session_tracker

import (
"math"
Expand All @@ -7,7 +7,7 @@ import (
"go.uber.org/zap"
)

const metricsNamespace = "tty_exporter"
const metricsNamespace = "local_session_tracker"

func InitMetrics(logger *zap.Logger) {
prometheus.MustRegister(prometheus.NewGaugeFunc(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tty_exporter
package local_session_tracker

import (
"encoding/json"
Expand Down
8 changes: 4 additions & 4 deletions test/testdata/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spec:
image: ghcr.io/cybozu/ubuntu:22.04
imagePullPolicy: IfNotPresent
command: [ "sleep", "infinity" ]
- name: tty-exporter
image: ghcr.io/cybozu-go/tty-exporter:0.0.1
- name: local-session-tracker
image: local-session-tracker:dev
imagePullPolicy: IfNotPresent
ports:
- name: sidecar
Expand Down Expand Up @@ -51,8 +51,8 @@ spec:
image: ghcr.io/cybozu/ubuntu:22.04
imagePullPolicy: IfNotPresent
command: [ "sleep", "infinity" ]
- name: tty-exporter
image: ghcr.io/cybozu-go/tty-exporter:0.0.1
- name: local-session-tracker
image: local-session-tracker:dev
imagePullPolicy: IfNotPresent
ports:
- name: sidecar
Expand Down

0 comments on commit 148ad1f

Please sign in to comment.