Skip to content

Commit eae7744

Browse files
bindiegoclaude
andcommitted
feat: implement comprehensive host configuration management with file-based system
This commit introduces a complete configuration file system for managing Elasticsearch and Kibana connection parameters, enhancing security and deployment flexibility. ## Key Changes: ### 1. Configuration File System (.gitignore) - Added .eshost and .kbnhost to .gitignore alongside existing .espass - Prevents accidental commit of sensitive host information - Ensures security across development, staging, and production environments ### 2. Makefile Configuration Enhancement - Updated eshost variable to read from .eshost file with fallback - Pattern: eshost := $(shell cat .eshost 2>/dev/null || echo "default_host") - Maintains consistency with existing .espass pattern - Enables environment-specific Elasticsearch host configuration for Dataflow deployments ### 3. Elasticsearch Setup Script Improvements (scripts/elastic/init.sh) - Enhanced es_client to read from .eshost file (project root) - Added kbn_host configuration from .kbnhost file (project root) - Fallback mechanism ensures backward compatibility - All configuration variables now follow consistent file-based pattern ### 4. Comprehensive Documentation Updates (readme.md) - Added step-by-step configuration instructions for all three files - Clarified usage patterns: makefile vs setup scripts - Enhanced security notes with detailed file usage breakdown - Updated step numbering and cross-references - Added examples for creating configuration files ## Configuration File Usage Matrix: | File | Makefile | Setup Scripts | Purpose | |-----------|----------|---------------|------------------------| | .espass | ✅ | ✅ | Elasticsearch password | | .eshost | ✅ | ✅ | Elasticsearch host URL | | .kbnhost | ❌ | ✅ | Kibana host URL | ## Benefits: - Environment-agnostic deployments (dev/staging/prod) - Enhanced security through git-ignored configuration files - Consistent configuration pattern across all components - Flexible host management without code changes - Backward compatibility with fallback defaults ## Migration: Existing deployments continue to work with default values. New deployments can create configuration files for custom environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a41a88d commit eae7744

4 files changed

Lines changed: 38 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
output-*
33
debug
44
.espass
5+
.eshost
6+
.kbnhost
57

68
##########################
79
## Java

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ workerType := e2-standard-2
55
workerZone := b
66
project := du-hast-mich
77
job := gclb
8-
eshost := https://k8es.ingest.bindiego.com
8+
eshost := $(shell cat .eshost 2>/dev/null || echo "https://k8es.ingest.bindiego.com")
99
esuser := elastic
1010
espass := $(shell cat .espass 2>/dev/null || echo "changeme")
1111
esindex := gclb-ingest

readme.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,27 @@ echo "your_elasticsearch_password" > .espass
5050

5151
This file is automatically ignored by git (configured in `.gitignore`) to prevent accidentally committing sensitive credentials. Both the makefile and Elasticsearch setup scripts will read the password from this file, with a fallback to "changeme" if the file doesn't exist.
5252

53-
2. Setup GCP
53+
2. **Configure Elasticsearch Host**
54+
55+
Create a `.eshost` file in the project root directory containing your Elasticsearch host URL:
56+
57+
```bash
58+
echo "https://your-elasticsearch-host.com" > .eshost
59+
```
60+
61+
This file is automatically ignored by git (configured in `.gitignore`) to prevent accidentally committing sensitive host information. Both the makefile and Elasticsearch setup scripts will read the Elasticsearch host from this file, with a fallback to "https://k8es.ingest.bindiego.com" if the file doesn't exist.
62+
63+
3. **Configure Kibana Host**
64+
65+
Create a `.kbnhost` file in the project root directory containing your Kibana host URL:
66+
67+
```bash
68+
echo "https://your-kibana-host.com" > .kbnhost
69+
```
70+
71+
This file is automatically ignored by git (configured in `.gitignore`) to prevent accidentally committing sensitive host information. The Elasticsearch setup script will read the Kibana host from this file, with a fallback to "https://k8na.bindiego.com" if the file doesn't exist.
72+
73+
4. Setup GCP
5474

5575
You could simply run `cd scripts && ./gcp_setup.sh; cd -`, but before that, make sure the parameters on the top have been updated according to your environment, especially the `project` variable, others are really optional.
5676

@@ -60,11 +80,16 @@ So this script will
6080
- Setup a Stackdriver sink (Pubsub) for HTTP load balancers
6181
- Grant permissions to the Service Account that been used by the sink, who will publish logs to Pubsub topic
6282

63-
3. Setup Elasticsearch & Kibana
83+
5. Setup Elasticsearch & Kibana
6484

6585
Same as GCP, there is a script can get the job done. Simply run `cd scripts/elastic && ./init.sh; cd -` then you done. Also, make sure you have updated the parameters on the top of the `init.sh` script according to your Elasticsearch setup.
6686

67-
**Note**: The Elasticsearch setup script will automatically use the password from the `.espass` file you created in step 1. Make sure your Elasticsearch cluster is accessible and the credentials are correct.
87+
**Note**: Both the makefile and Elasticsearch setup script will automatically use:
88+
- The password from the `.espass` file you created in step 1
89+
- The Elasticsearch host from the `.eshost` file you created in step 2
90+
- The Kibana host from the `.kbnhost` file you created in step 3
91+
92+
Make sure your Elasticsearch cluster and Kibana instance are accessible and the credentials are correct.
6893

6994
This script will
7095

@@ -91,7 +116,11 @@ Double check the paramters passed to the job trigger in `makefile`, then,
91116
make df
92117
```
93118

94-
**Security Note**: All makefile commands automatically use the Elasticsearch password from your `.espass` file, ensuring secure credential handling across development and production environments.
119+
**Security Note**: Configuration files are automatically used as follows:
120+
- **Makefile commands**: Use `.espass` and `.eshost` files for Elasticsearch connection
121+
- **Setup scripts**: Use `.espass`, `.eshost`, and `.kbnhost` files for complete configuration
122+
123+
This ensures secure credential handling and flexible configuration across development and production environments.
95124

96125
###### FAQs 常见问题
97126

scripts/elastic/init.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
pwd=`pwd`
77
project_root="$(cd "$pwd/../.." && pwd)"
88

9-
es_client=https://k8es.client.bindiego.com
10-
kbn_host=https://k8na.bindiego.com
9+
es_client=$(cat "$project_root/.eshost" 2>/dev/null || echo "https://k8es.client.bindiego.com")
10+
kbn_host=$(cat "$project_root/.kbnhost" 2>/dev/null || echo "https://k8na.bindiego.com")
1111
es_user=elastic
1212
es_pass=$(cat "$project_root/.espass" 2>/dev/null || echo "changeme")
1313

0 commit comments

Comments
 (0)