Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit aad5379

Browse files
author
Shawn Hurley
authored
Merge pull request #34 from dymurray/ansible
Add samples for Ansible Operator
2 parents d90c6ef + bc271af commit aad5379

File tree

138 files changed

+5026
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+5026
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ This project is a component of the [Operator Framework](https://github.com/opera
33
# Operator SDK Samples
44
This repo contains samples of operators built using the [operator-sdk][operator_sdk].
55

6+
To view operators which leverage Ansible for deployment, see the [Ansible][ansible_examples] samples section.
7+
68
[operator_sdk]:https://github.com/coreos/operator-sdk
9+
[ansible_examples]:./ansible/

ansible/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This project is a component of the [Operator Framework](https://github.com/operator-framework), an open source toolkit to manage Kubernetes native applications, called Operators, in an effective, automated, and scalable way. Read more in the [introduction blog post](https://coreos.com/blog/introducing-operator-framework).
2+
3+
# Operator SDK Samples - Ansible
4+
This repo contains samples of operators powered by Ansible built using the [operator-sdk][operator_sdk]. To learn more about creating an operator that leverages Ansible, check out the [Ansible user guide][ansible_user_guide].
5+
6+
[operator_sdk]:https://github.com/coreos/operator-sdk
7+
[ansible_user_guide]:https://github.com/operator-framework/operator-sdk/blob/master/doc/ansible/user-guide.md

ansible/bitcoin-sv-operator/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# bitcoin-sv-operator
2+
3+
This is an Operator which deploys [Bitcoin Satoshi Vision (SV)](https://github.com/bitcoin-sv/bitcoin-sv) - a Bitcoin Cash full node implementation - on Kubernetes/Openshift.
4+
5+
This Operator is an [Ansible Operator](https://github.com/water-hole/ansible-operator) which deploys a containerized version of `bitcoind` with RPC and REST capabilities.
6+
7+
This project was generated using [operator-sdk](https://github.com/operator-framework/operator-sdk).
8+
9+
To deploy the operator:
10+
```
11+
$ kubectl create -f deploy/rbac.yaml
12+
$ kubectl create -f deploy/crd.yaml
13+
$ kubectl create -f deploy/operator.yaml
14+
```
15+
16+
To launch an instance of Bitcoin SV:
17+
```
18+
$ kubectl create -f deploy/cr.yaml
19+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: "bitcoin-sv.example.com/v1alpha1"
2+
kind: "Bitd"
3+
metadata:
4+
name: "example"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: bitds.bitcoin-sv.example.com
5+
spec:
6+
group: bitcoin-sv.example.com
7+
names:
8+
kind: Bitd
9+
listKind: BitdList
10+
plural: bitds
11+
singular: bitd
12+
scope: Namespaced
13+
version: v1alpha1
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: bitd-operator
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
name: bitd-operator
10+
template:
11+
metadata:
12+
labels:
13+
name: bitd-operator
14+
spec:
15+
containers:
16+
- name: bitd-operator
17+
image: docker.io/dymurray/bitd-operator
18+
ports:
19+
- containerPort: 60000
20+
name: metrics
21+
imagePullPolicy: Always
22+
env:
23+
- name: WATCH_NAMESPACE
24+
valueFrom:
25+
fieldRef:
26+
fieldPath: metadata.namespace
27+
- name: OPERATOR_NAME
28+
value: "bitd-operator"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
kind: ClusterRole
2+
apiVersion: rbac.authorization.k8s.io/v1beta1
3+
metadata:
4+
name: bitd-operator
5+
rules:
6+
- apiGroups:
7+
- bitcoin-sv.example.com
8+
resources:
9+
- "*"
10+
verbs:
11+
- "*"
12+
- apiGroups:
13+
- ""
14+
resources:
15+
- pods
16+
- services
17+
- endpoints
18+
- persistentvolumeclaims
19+
- events
20+
- configmaps
21+
- secrets
22+
verbs:
23+
- "*"
24+
- apiGroups:
25+
- apps
26+
resources:
27+
- deployments
28+
- daemonsets
29+
- replicasets
30+
- statefulsets
31+
verbs:
32+
- "*"
33+
34+
---
35+
36+
kind: ClusterRoleBinding
37+
apiVersion: rbac.authorization.k8s.io/v1beta1
38+
metadata:
39+
name: default-account-bitd-operator
40+
subjects:
41+
- kind: ServiceAccount
42+
name: default
43+
namespace: default
44+
roleRef:
45+
kind: ClusterRole
46+
name: bitd-operator
47+
apiGroup: rbac.authorization.k8s.io
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Role Name
2+
=========
3+
4+
A brief description of the role goes here.
5+
6+
Requirements
7+
------------
8+
9+
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10+
11+
Role Variables
12+
--------------
13+
14+
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15+
16+
Dependencies
17+
------------
18+
19+
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20+
21+
Example Playbook
22+
----------------
23+
24+
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25+
26+
- hosts: servers
27+
roles:
28+
- { role: username.rolename, x: 42 }
29+
30+
License
31+
-------
32+
33+
BSD
34+
35+
Author Information
36+
------------------
37+
38+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# defaults file for Bitd
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# handlers file for Bitd
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
galaxy_info:
2+
author: your name
3+
description: your description
4+
company: your company (optional)
5+
6+
# If the issue tracker for your role is not on github, uncomment the
7+
# next line and provide a value
8+
# issue_tracker_url: http://example.com/issue/tracker
9+
10+
# Some suggested licenses:
11+
# - BSD (default)
12+
# - MIT
13+
# - GPLv2
14+
# - GPLv3
15+
# - Apache
16+
# - CC-BY
17+
license: license (GPLv2, CC-BY, etc)
18+
19+
min_ansible_version: 1.2
20+
21+
# If this a Container Enabled role, provide the minimum Ansible Container version.
22+
# min_ansible_container_version:
23+
24+
# Optionally specify the branch Galaxy will use when accessing the GitHub
25+
# repo for this role. During role install, if no tags are available,
26+
# Galaxy will use this branch. During import Galaxy will access files on
27+
# this branch. If Travis integration is configured, only notifications for this
28+
# branch will be accepted. Otherwise, in all cases, the repo's default branch
29+
# (usually master) will be used.
30+
#github_branch:
31+
32+
#
33+
# platforms is a list of platforms, and each platform has a name and a list of versions.
34+
#
35+
# platforms:
36+
# - name: Fedora
37+
# versions:
38+
# - all
39+
# - 25
40+
# - name: SomePlatform
41+
# versions:
42+
# - all
43+
# - 1.0
44+
# - 7
45+
# - 99.99
46+
47+
galaxy_tags: []
48+
# List tags for your role here, one per line. A tag is a keyword that describes
49+
# and categorizes the role. Users find roles by searching for tags. Be sure to
50+
# remove the '[]' above, if you add tags to this list.
51+
#
52+
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
53+
# Maximum 20 tags per role.
54+
55+
dependencies: []
56+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
57+
# if you add dependencies to this list.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
# tasks file for Bitd
3+
- name: start bitd
4+
k8s:
5+
definition:
6+
kind: Deployment
7+
apiVersion: apps/v1
8+
metadata:
9+
name: '{{ meta.name }}-bitd'
10+
namespace: '{{ meta.namespace }}'
11+
spec:
12+
selector:
13+
matchLabels:
14+
app: bitd
15+
template:
16+
metadata:
17+
labels:
18+
app: bitd
19+
spec:
20+
containers:
21+
- name: bitd
22+
image: "docker.io/dymurray/bitcoin-sv-bitd"
23+
ports:
24+
- containerPort: 8332
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
localhost
2+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- hosts: localhost
3+
remote_user: root
4+
roles:
5+
- Bitd
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# vars file for Bitd
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM quay.io/water-hole/ansible-operator
2+
3+
COPY roles/ ${HOME}/roles/
4+
COPY watches.yaml ${HOME}/watches.yaml
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
if ! which docker > /dev/null; then
4+
echo "docker needs to be installed"
5+
exit 1
6+
fi
7+
8+
: ${IMAGE:?"Need to set IMAGE, e.g. gcr.io/<repo>/<your>-operator"}
9+
10+
echo "building container ${IMAGE}..."
11+
docker build -t "${IMAGE}" -f tmp/build/Dockerfile .
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- version: v1alpha1
3+
group: bitcoin-sv.example.com
4+
kind: Bitd
5+
role: /opt/ansible/roles/Bitd/

ansible/etcd-operator/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
etcd-ansible-operator.iml

0 commit comments

Comments
 (0)