'cloud'에 해당되는 글 7건

  1. 2020.08.31 [Elastic] IaC 기반의 Cluster 관리
  2. 2020.06.25 [Spring] Spring Cloud Config 설정 파일 적용
  3. 2020.06.18 [Spring] Spring Cloud Config 다중 Backend 사용 시...
  4. 2020.06.16 [Spring] @RefreshScope 적용 시 반영이 잘 안될 때
  5. 2020.04.21 [Spring] Spring Cloud Config Client 구성 시 주의점
  6. 2020.03.26 [AWS] Spring Cloud Config S3 Backend 사용하기
  7. 2008.03.28 [펌] cloud computing

[Elastic] IaC 기반의 Cluster 관리

Elastic 2020. 8. 31. 12:40

Elastic Stack 은 서비스나 데이터를 다루는 모든 기업에서 사용을 하고 있는 매우 훌륭한 오픈소스 입니다.

 

기본적으로 

  • Elasticsearch
  • Kibana
  • Logstash
  • Beats

이 4가지 Stack 을 이야기 하고 있으며,

잘 활용 하실 경우 현존 하는 많은 상용 도구들을 모두 재낄 수 있습니다.

 

단, 기술 내재화와 역량을 확보 하겠다는 의지가 있을 경우에 한해서 입니다.

 

제가 지금까지 다니던 회사는 주로 서비스 회사 였기 때문에,

특정 도메인에 필요로 하는 기능 개발과 스타트업 특성에 따른 빠른 개발을 할 수 밖에 없었습니다.

올해 회사를 옮기면서 그 동안 만나 봤던 분들의 어려움을 해결 할 수 있는 방법은 없을까 하고 고민 하다,

Elastic Stack 에 대한 설치 자동화 프로그램을 만들어 보기로 했습니다.

 

그 결과로 우선 1차 버전을 이야기 해볼까 합니다.

 

Elasticsearch 는 누구나 쉽게 사용이 가능 합니다.

검색 (IR) 에 대한 지식이나 전문성이 없어도 Elasticsearch 를 도구적으로 설치 하고 사용 하는 데는 별 문제가 없습니다.

그래서 빠른 PoC 작업을 할 수도 있는 것 같습니다.

 

하지만 클러스터를 구성 하고 이를 운영 하면서 인프라 관점으로 접근 하다 보면 어려움이 생기게 됩니다.

  • 사용하고자 하는 부서는 많고,
  • 그렇다고 단일 클러스터로 구성해서 사용하라고 제공해 줄 수도 없고,
  • 인프라 생성 요청도 해야 하고,
  • 설정 및 설치도 해야 하고,
  • 문제가 생기면 위 과정을 다시 반복 해야 하고,
  • 클러스터 최적화는 또 어떻게 해야 하고,

등등....

 

요청자와 생성자의 편의를 제공 할 수 있으면 어떨까 싶었습니다.

 

제가 만들어 본 Application 은 아래 Stack 을 이용해서 개발이 되었습니다.

  • Spring Framework
  • Terraform
  • Ansible
  • Docker
  • AWS (EC2, S3)
  • Elasticsearch

AWS 기반으로 먼저 개발을 진행을 했고 추후 Azure 나 GCP 로도 확장을 할 예정입니다.

 

기본 동작 방식은 아래와 같습니다.

1.  Application Container

  - 인프라 구성을 위한 정보를 설정 하고 설치 파일을 생성 합니다.

    - Terraform 관련 파일을 생성 합니다. (setup.tf)

  - 생성 될 인스턴스에 설치 할 정보를 설정하고 설치 파일을 생성 합니다. 

    - Ansible 관련 파일을 생성 합니다. (playbook, inventories, roles)

  - 클러스터 구성을 위한 정보를 설정 하고 설치 파일을 생성 합니다.

    - Docker Compose 관련 파일을 생성 합니다. (docker-compose.yml)

2. Terraform Backend - S3

  - Terraform 을 이용해서 생성한 인스턴스의 정보는 s3 backend 에 저장이 됩니다.

3. Bastion

  - 설치 시 보안 관리를 위해 bastion 서버로 ssh tunneling 하여 설치 합니다.

 

화면 구성은 아래와 같습니다.

 

그림 1) Terraform 설정 정보와 Elasticsearch Cluster Node Topology 설정 및 실행 화면

그림 2) Ansible 을 이용한 Node 환경 구성 설정 및 실행 화면

그림 3) Elasticsearch Cluster 실행 화면

그림 4) 생성 된 Cluster 에 대한 목록 및 관리 화면

그림 5) 개별 클러스터의 Node 에 대한 관리 화면

 

만들어진 Application 은 도커 기반으로 개발이 되어 있기 때문에 어떤 환경에서든 실행이 가능 합니다.
가장 기초적인 부분에서 부터 출발한 것으로 

  • 클러스터 구성 및 설치는 어떻게 해야 하는가?
  • 클러스터 구성 시 최적화는 되어 있는가?
  • 클러스터를 쉽게 생성 하고 삭제 할 수 있는가?
  • 이미 생성된 클러스터에 노드 추가는 어떻게 해야 하는가?
  • 개별 노드들에 대한 시작과 중지를 할 수 있는가?

등등...

 

보시는 바와 같이 클러스터의 생성에서 부터 시작과 중지에 대한 기초 부터 접근을 했습니다.

 

Elasticsearch 는 크게 3 가지 유형으로 사용을 하게 됩니다.

  • 검색
  • 저장(색인)
  • 분석

 

위 3 가지 유형을 가지고 Business Domain 별 사용을 하게 되는 것입니다.

  • e-Commerce 상품 검색
  • SIEM
  • Log 및 Data 분석 시스템

등등 ...

 

이걸 좀 더 고도화 한다고 하면 아래와 같은 서비스들을 쉽게 만들수도 있습니다.

  • AWS Elasticsearch Service
  • Elastic Cloud - Elasticsearch

회사에서 어떤 전략으로 접근 할 지 아직은 잘 모르겠습니다.

이미 IaC 기반으로 잘 제공 되고 있는 MSP (Elastic, AWS) 가 있는데, 우리가 이것 까지 해야 할까?

 

이 문제는 뒤로 하고,

Elasticsearch 를 사용하거나 사용하고자 하는 스타트업이 있다면,

누구라도 쉽게 최적화된 클러스터를 생성하고 인프라를 관리 할 수 있도록 제공하면 좋겠다는게 지금 저의 생각 입니다.

 

오픈소스로 공개를 해도 되고, 컨테이너 이미지를 docker registry 에 등록을 해도 되고 몇 가지 방법이 있겠지만,

정말 이런게 필요한지 부터 고민을 더 해봐야 할 것 같습니다.

 

아무도 필요로 하지 않는데 계속 투자를 해야 할지도 고민이라서요. ^^;

 

ECOS(Elastic Cloud Open Stack) Installer 의 기능을 간략하게 요약해 드리면,

  1. Elasticsearch Cluster 구성을 위한 GUI 환경을 제공 합니다.
  2. Terraform 기반의 리소스 생성을 제공 합니다.
  3. Ansible 기반의 설치 및 운영 환경을 제공 합니다.
  4. Docker 기반의 Cluster 환경 구성 및 관리 기능을 제공 합니다.
  5. Elasticsearch 설정을 잘 몰라도 됩니다. (이왕이면 알면 좋습니다.)
  6. Cluster 환경을 최적화 해서 구성해 줍니다.
  7. Terraform, Ansible, Docker 등에 대해서 잘 몰라도 됩니다. (이왕이면 알면 좋습니다.)
  8. 리소스를 쉽게 제공하고 회수 할 수 있습니다.
  9. Cluster 내 Node 추가 기능을 제공 합니다.

ECOS Installer 는 우선

  • MZC( Megazone Cloud) 고객사 중
  • 기술 내재화를 고민 하고 계신 고객사

를 찾아서 설치 및 기술 이전을 해보려 합니다.

 

피드백을 받아 가면서 업그레이드를 해보도록 하겠습니다.

 

감사합니다.

:

[Spring] Spring Cloud Config 설정 파일 적용

ITWeb/개발일반 2020. 6. 25. 14:29

spring config client  에 server config 파일이 존재 할 경우 적용 안되는 문제를 해결 하기 위해 아래 설정을 하면 됩니다.

 

https://cloud.spring.io/spring-cloud-static/spring-cloud-commons/2.2.2.RELEASE/reference/html/#overriding-bootstrap-properties

 

1.4. Overriding the Values of Remote Properties

The property sources that are added to your application by the bootstrap context are often “remote” (from example, from Spring Cloud Config Server). By default, they cannot be overridden locally. If you want to let your applications override the remote properties with their own system properties or config files, the remote property source has to grant it permission by setting spring.cloud.config.allowOverride=true (it does not work to set this locally). Once that flag is set, two finer-grained settings control the location of the remote properties in relation to system properties and the application’s local configuration:

  • spring.cloud.config.overrideNone=true: Override from any local property source.

  • spring.cloud.config.overrideSystemProperties=false: Only system properties, command line arguments, and environment variables (but not the local config files) should override the remote settings.

spring:
  cloud:
    config:
      uri: xxxx
      allowOverride: true
      overrideNone: true
      overrideSystemProperties: false

 

:

[Spring] Spring Cloud Config 다중 Backend 사용 시...

ITWeb/개발일반 2020. 6. 18. 10:41

Spring Cloud Config 를 이용해서 다중 Backend 를 구성 할 수 있습니다.

그러나 order 옵션이 저는 제대로 동작 하지 않아서 실행 시 사용해야 하는 Backend 에 대한 profile 로 관리하기로 했습니다.

 

동시에 두 개의 Backend 를 사용 하는 것도 가능 한데 이게 같은 설정 파일이 양쪽에 다 존재 할 때 order 에 맞춰서 설정 정보를 가져 와야 하는데 이상하게도 git 에 있는 설정을 먼저 가져 와서 목적에 맞게 사용을 할 수 없었습니다.

 

spring:
  application:
    name: config-server
  profiles:
    active: awss3, git
  cloud:
    config:
      server:
        awss3:
          region: ap-northeast-2
          bucket: ${BUCKET-NAME}
          order: 1
        git:
          uri: https://git/config-repo.git
          skipSslValidation: true
          username: xxxxx
          password: xxxxx
          clone-on-start: true
          order: 2

저렇게 설정 하고 했었는데 잘 못된 부분이 있다면 댓글 좀 달아 주세요. :)

 

profile을 실행 시점에 awss3 나 git 으로 설정해서 사용 하도록 마무리 했습니다.

:

[Spring] @RefreshScope 적용 시 반영이 잘 안될 때

ITWeb/개발일반 2020. 6. 16. 14:51

일단 spring config server 에서 설정을 변경해서 적용 합니다.

 

POST , /actuator/refresh 를  실행 합니다.

 

그럼 기대 하는 건 변경 된 설정 값이 반영이 되어 있어야 한다는 것입니다.

 

그러나 반영이 안되어 있어서 디버깅 하다 아래와 같이 event 를 잡아서 처리를 해주니 잘되는 것을 확인 했습니다.

 

  @EventListener(RefreshScopeRefreshedEvent.class)
  public void onRefresh() {
    log.debug("triggering ----> {}", watcherThreshold);
  }

참고해서 보셔야 하는 코드는 아래 입니다.

/*
 * Copyright 2012-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.cloud.context.scope.refresh;

import java.io.Serializable;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.cloud.context.scope.GenericScope;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;

/**
 * <p>
 * A Scope implementation that allows for beans to be refreshed dynamically at runtime
 * (see {@link #refresh(String)} and {@link #refreshAll()}). If a bean is refreshed then
 * the next time the bean is accessed (i.e. a method is executed) a new instance is
 * created. All lifecycle methods are applied to the bean instances, so any destruction
 * callbacks that were registered in the bean factory are called when it is refreshed, and
 * then the initialization callbacks are invoked as normal when the new instance is
 * created. A new bean instance is created from the original bean definition, so any
 * externalized content (property placeholders or expressions in string literals) is
 * re-evaluated when it is created.
 * </p>
 *
 * <p>
 * Note that all beans in this scope are <em>only</em> initialized when first accessed, so
 * the scope forces lazy initialization semantics.
 * </p>
 *
 * <p>
 * The scoped proxy approach adopted here has a side benefit that bean instances are
 * automatically {@link Serializable}, and can be sent across the wire as long as the
 * receiver has an identical application context on the other side. To ensure that the two
 * contexts agree that they are identical, they have to have the same serialization ID.
 * One will be generated automatically by default from the bean names, so two contexts
 * with the same bean names are by default able to exchange beans by name. If you need to
 * override the default ID, then provide an explicit {@link #setId(String) id} when the
 * Scope is declared.
 * </p>
 *
 * @author Dave Syer
 * @since 3.1
 *
 */
@ManagedResource
public class RefreshScope extends GenericScope implements ApplicationContextAware,
		ApplicationListener<ContextRefreshedEvent>, Ordered {

	private ApplicationContext context;

	private BeanDefinitionRegistry registry;

	private boolean eager = true;

	private int order = Ordered.LOWEST_PRECEDENCE - 100;

	/**
	 * Creates a scope instance and gives it the default name: "refresh".
	 */
	public RefreshScope() {
		super.setName("refresh");
	}

	@Override
	public int getOrder() {
		return this.order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	/**
	 * Flag to determine whether all beans in refresh scope should be instantiated eagerly
	 * on startup. Default true.
	 * @param eager The flag to set.
	 */
	public void setEager(boolean eager) {
		this.eager = eager;
	}

	@Override
	public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
			throws BeansException {
		this.registry = registry;
		super.postProcessBeanDefinitionRegistry(registry);
	}

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		start(event);
	}

	public void start(ContextRefreshedEvent event) {
		if (event.getApplicationContext() == this.context && this.eager
				&& this.registry != null) {
			eagerlyInitialize();
		}
	}

	private void eagerlyInitialize() {
		for (String name : this.context.getBeanDefinitionNames()) {
			BeanDefinition definition = this.registry.getBeanDefinition(name);
			if (this.getName().equals(definition.getScope())
					&& !definition.isLazyInit()) {
				Object bean = this.context.getBean(name);
				if (bean != null) {
					bean.getClass();
				}
			}
		}
	}

	@ManagedOperation(description = "Dispose of the current instance of bean name "
			+ "provided and force a refresh on next method execution.")
	public boolean refresh(String name) {
		if (!name.startsWith(SCOPED_TARGET_PREFIX)) {
			// User wants to refresh the bean with this name but that isn't the one in the
			// cache...
			name = SCOPED_TARGET_PREFIX + name;
		}
		// Ensure lifecycle is finished if bean was disposable
		if (super.destroy(name)) {
			this.context.publishEvent(new RefreshScopeRefreshedEvent(name));
			return true;
		}
		return false;
	}

	@ManagedOperation(description = "Dispose of the current instance of all beans "
			+ "in this scope and force a refresh on next method execution.")
	public void refreshAll() {
		super.destroy();
		this.context.publishEvent(new RefreshScopeRefreshedEvent());
	}

	@Override
	public void setApplicationContext(ApplicationContext context) throws BeansException {
		this.context = context;
	}

}

 

refreshAll() 을 호출 하게 되어서 반영이 잘됩니다.

 

더불어 그냥 프레임워크에서 제공하는 @Scheduled 사용 하십시오.

 

  @Scheduled(fixedDelayString = "${megatoi.watcher.cpu.period}000")
  private void runner() {
    megatoiCheckerUtil.setWatcherThreshold(watcherThreshold);
    megatoiCheckerUtil.setPayload(getCheckQuery());
    megatoiCheckerUtil.setResourceType(ResourceType.CPU);
    megatoiCheckerUtil.commonRunner();
  }
:

[Spring] Spring Cloud Config Client 구성 시 주의점

ITWeb/개발일반 2020. 4. 21. 16:35

주의점 이라기 보다 그냥 설정을 잘 못 하는 경우가 있어서 기록 합니다.

 

Client 쪽 Dependency 등록)

implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

 

Client 쪽 bootstrap.yml 등록)

spring:
  cloud:
    config:
      uri: http://${CONFIG_SERVER_HOST}:${PORT}

management:
  endpoints:
    web:
      exposure:
        include: refresh

 

Refresh 호출)

- HTTP Method : POST

- http://${CONFIG_CLIENT_HOST}:${PORT}/actuator/refresh

 

bootstrap.yml 에 등록 하지 않게 되면 client 가 config server 를 localhost:8888 로 찾는 오류가 발생 할 수 있습니다.

또한 refresh 등록을 해줘야 actuator/refresh 사용이 가능 합니다.

 

:

[AWS] Spring Cloud Config S3 Backend 사용하기

Cloud&Container/AWS 2020. 3. 26. 10:57

Spring Cloud Config Server 설정)

 

[S3 설정]
- S3 버킷 생성
- 접근권한 부여

[ConfigApplication.java]

@SpringBootApplication
@EnableConfigServer
public class ConfigApplication {
  public static void main(String[] args) {
	SpringApplication.run(ConfigApplication.class, args);
  }
}


[build.gradle]

compile 'com.amazonaws:aws-java-sdk-s3'


[application.yml]

server:
port: 8888

spring:
  profiles:
    active: awss3
  cloud:
    config:
      server:
        awss3:
          region: ap-northeast-2
          bucket: s3config


[Config Server 접근 URL]

http://localhost:8888/${S3-FILE-NAME}/${PROFILE-NAME}

- 생성한 버킷 하위로 설정 파일 목록이 존재 해야 합니다.
- ${S3-FILE-NAME} 는 생성한 Bucket 아래 만든 설정 파일명 입니다.
- backoffice
- ${PROFILE-NAME} 은 설정 파일에 대한 프로필명 입니다.
- app1, app2

예제)
Config Server URL : 
http://localhost:8888/backoffice/app1

S3 :
megatoidiscons3config/backoffice-app1.yml
or
megatoidiscons3config/backoffice-app1.properties


[backoffice-app1.yml]

project.app1="backoffice-app1"


[backoffice-app2.yml]

project.app2="backoffice-app2"

 

Spring Cloud Config Client 설정)

[application.yml]

spring:
  cloud:
    config:
      name: backoffice
      uri: http://localhost:8888
      profile: app1,app2


[HelloController.java]

@RestController
public class HelloController {

  @Value ("${project.app1}")
  String projectApp1;

  @Value ("${project.app2}")
  String projectApp2;

  @RequestMapping("/app1")
  public String helloApp1() {
    return projectApp1;
  }

  @RequestMapping("/app2")
  public String helloApp2() {
    return projectApp2;
  }
}

 

git 사용 하는 건 문서들이 많이 나와 있어서 s3 로 정리해 봤습니다.

:

[펌] cloud computing

ITWeb/스크랩 2008. 3. 28. 11:15
ref. http://en.wikipedia.org/wiki/Cloud_computing

Cloud computing

From Wikipedia, the free encyclopedia

Jump to: navigation, search

Cloud computing is a new (circa late 2007) label for the subset of grid computing that includes utility computing and other approaches to the use of shared computing resources. Cloud computing is an alternative to having local servers or personal devices handling users' applications.

In general, the label suggests that function comes from "the cloud" -- often understood to mean a public network, usually assumed to be the Internet -- rather than from a specific identifiable device. The label of "cloud computing" is not, however, identical with the business model of software as a service or the usage model of utility computing. Grid computing is a technology approach to manage a cloud. In effect, all clouds are managed by a grid but not all grids manage cloud. Specifically a computer grid and a cloud are synonymous while a data grid and a cloud can be different.

Within the general label, though, it is an easy error to assume that all clouds are created equal. This can lead to confusion and disappointment.

For example, virtualization of servers on a shared super-server can speed the deployment of new capability, since no new hardware needs to be installed, but the software stack that runs on the virtual server must still be configured and updated -- unlike the case with a multi-tenant software-as-a-service capability.

A computer cluster can offer cost-effective service in specific applications, but may be limited to a single type of computing node that allows all nodes to run a common operating system. Alternatively, the canonical definition of grid is one that allows any type of processing engine to enter or leave the system, dynamically, by analogy to an electrical power grid on which any given generating plant might be active or inactive at any given time.

However, an electrical generator only needs to produce volts and amperes in synchrony with other units on the grid, while computing cycles are not nearly such an undifferentiated commodity. For example, a computing grid could include both general-purpose processors and specialized units such as a vector processor facility.

Also important to the notion of cloud computing is the automation of many management tasks. If the system requires human management to allocate processes to resources, it's not a cloud: it's just a data center.

The applications of cloud/utility computing models are expanding rapidly as connectivity costs fall, and as evolution of processor architectures favors the development of multi-core systems with intrinsically parallel computing hardware that greatly exceeds the parallelization potential of most applications. The economic incentives to share hardware among multiple users are increasing; the drawbacks in performance and interactive response that used to discourage remote and distributed computing solutions are being greatly reduced.

As a result, the services that can be delivered from the cloud are not limited to web applications, but may also include storage, raw computing, or access to any number of specialized services.

Common visualizations of a cloud computing approach include, but should not be considered to be limited by, the following:

Contents

[hide]

[edit] Potential advantages

Potential advantages of any cloud or grid computing approach include:

  • location of infrastructure in areas with lower costs of space and electricity
  • sharing of peak-load capacity among a large pool of users, improving overall utilization
  • separation of infrastructure maintenance duties from domain-specific application development

[edit] Ensembles

While most traditional IT clouds are made up of heterogeneous systems, an ensemble is a pool of homogenous systems within the cloud which are compatible with one another. These ensembles are integrated by virtualization and management software which allow for mobility of the software stack between physical servers. It can scale from a few servers to many thousands, while having the management complexity near that of a single system. For instance an ensemble could be a set of systems which are capable of running a certain web appliance stack. The operating system, middleware, and web-app run exactly the same between servers in the ensemble.

[edit] Architecture

 
Diagram of cloud computing architecture.

The architecture behind cloud computing is a massive network of "cloud servers" interconnected as if in a grid running in parallel, sometimes using the technique of virtualization to maximize computing power per server.

A front-end interface allows a user to select a service from a catalog. This request gets passed to the system management which finds the correct resources, and then calls the provisioning services which carves out resources in the cloud. The provisioning service may deploy the requested stack or web application as well.

  • User interaction interface: This is how users of the cloud interface with the cloud to request services.
  • Services catalog: This is the list of services that a user can request.
  • System management: This is the piece which manages the computer resources available.
  • Provisioning tool: This tool carves out the systems from the cloud to deliver on the requested service. It may also deploy the required images.
  • Monitoring and metering: This optional piece tracks the usage of the cloud so the resources used can be attributed to a certain user.
  • Servers: The servers are managed by the system management tool. They can be either virtual or real.

[edit] Cloud storage

Cloud storage is a model of networked data storage where data is stored on multiple virtual servers, generally hosted by third parties, rather than being hosted on dedicated servers. Hosting companies operate large data centers; and people who require their data to be hosted buy or lease storage capacity from them and use it for their storage needs. The data center operators, in the background, virtualize the resources according to the requirements of the customer and expose them as virtual servers, which the customers can themselves manage. Physically, the resource may span across multiple servers.

[edit] Cloud services

Cloud services refers to web services offered via cloud computing. Amazon is probably the first company to start selling Cloud based services in the form of its Amazon Elastic Compute Cloud, popularly known as Amazon EC2, a part of Amazon's web services platform. Currently in its beta version, it provides computing capacity in the cloud to run applications

: