Permalink
Browse files

Initial implementation of <kubernetes-container-terminal>

  • Loading branch information...
stefwalter committed Oct 7, 2015
1 parent cd7ed1e commit 9ac579db69e36a91c3d1474d89acd179cf071de6
Showing with 1,334 additions and 0 deletions.
  1. +502 −0 COPYING
  2. +92 −0 Gruntfile.js
  3. +114 −0 README.md
  4. +38 −0 bower.json
  5. +49 −0 container-terminal.css
  6. +200 −0 container-terminal.js
  7. +49 −0 dist/container-terminal.css
  8. +200 −0 dist/container-terminal.js
  9. +73 −0 index.html
  10. +17 −0 package.json
  11. BIN scratch/sceenshot.png
View
502 COPYING

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,92 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['container-terminal.js'],
dest: 'dist/container-terminal.js'
},
css: {
src: ['container-terminal.css'],
dest: 'dist/container-terminal.css'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/container-terminal.min.js': ['<%= concat.dist.dest %>']
}
}
},
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
define: true,
console: true,
document: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'qunit'],
css: {
files: 'container-terminal.css'
},
js: {
files: [
'container-terminal.js',
'container-terminal.css',
'index.html'
],
tasks: ['build']
}
},
// The actual grunt server settings
connect: {
options: {
protocol: grunt.option('scheme') || 'http',
port: grunt.option('port') || 9000,
hostname: grunt.option('hostname') || 'localhost'
},
server: {}
},
run: {
bower: {
cmd: 'node_modules/.bin/bower',
args: [ "update" ]
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-run');
grunt.registerTask('serve', [
'build',
'connect:server',
"watch"
]);
grunt.registerTask('build', [
'concat',
'jshint'
]);
grunt.registerTask('default', ['serve']);
grunt.registerTask('depends', [ "run:bower" ]);
};
View
114 README.md
@@ -0,0 +1,114 @@
Kubernetes Container Terminal
=============================
Provides a simple container TTY for Kubernetes pods.
#### Disclaimer
This is an early implementation and is subject to change.
![Screenshot](https://raw.githubusercontent.com/kubernetes-ui/container-terminal/master/scratch/sceenshot.png)
Getting Started
---------------
The kubernetes terminal is provided in the kubernetes-container-terminal bower package.
To get the kubernetes-container-terminal bower component in another project, run:
```
bower install kubernetes-container-terminal --save
```
To see a simple running example git clone this repo and run
```
npm install
grunt depends
firefox index.html
```
This will install any required dependencies necessary to run the ```index.html``` demo.
Usage
-----
Include the JS and CSS files, after angularjs and d3:
```xml
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/term.js/src/term.js"></script>
<script src="bower_components/kubernetes-container-terminal/dist/container-terminal.js"></script>
<link rel="stylesheet" href="bower_components/kubernetes-container-terminal/dist/container-terminal.css" />
```
Make sure your angular app / module includes ```kubernetesUI``` as a module dependency.
```
angular.module('exampleApp', ['kubernetesUI'])
```
Now include the graph:
```xml
<kubernetes-container-terminal >
</kubernetes-container-terminal>
```
Documentation
-------------
#### =url
An optional base URL of the API endpoint. If a ```resource``` is specified, then
the ```resource.metadata.selfLink``` will be added to this URL. If no resource
is specified, then the url will will be used as is. If not specified, then the
URL will be automatically determined from the current document location. This URL
should start with either ```ws://``` or ```wss://```.
#### =resource
An optional Kubernetes resource Pod object. If set, the ```resource.metadata.selfLink```
will be added to the ```url```.
#### =container
The name of the container in the Pod to open the terminal for. If not specified then
Kubernetes will connect to one of the containers.
#### =command
The command to run. Either an executable string, or an array containing the executable
and all the arguments. If not specified will default to running an interactive shell.
#### =state
Reflects the current state of the connection. These are the same as the WebSocket
readyState constants. The following values:
* CONNECT = null
* CONNECTING = 0
* OPEN = 1
* CLOSING = 2
* CLOSED = 3
In particular, if the caller sets the state to CLOSED or CLOSING, then the terminal
will close its connection. If the state is set to CONNECT then the terminal will
connect (or reconnect), and change the state as it does so.
#### =constructor
Optional constructor function to use to create the WebSocket.
Styling
-------
See ```container-terminal.css``` for an example default look and feel.
Contributing
------------
Git clone this repo and run `grunt serve`. While the server is running, any time changes
are made to the JS or HTML files the build will run automatically. Before committing any
changes run the `grunt build` task to make sure dist/container-terminal.js has been updated
and include the updated file in your commit.
View
@@ -0,0 +1,38 @@
{
"name": "kubernetes-container-terminal",
"version": "0.0.1",
"description": "Provides a terminal for a kubernetes container in a pod.",
"moduleType": [
"globals"
],
"keywords": [
"kubernetes",
"angularjs",
"termjs"
],
"authors": [
"Stef Walter <stefw@redhat.com>"
],
"ignore": [
"**/.*",
"Gruntfile.js",
"*.html",
"package.json",
"/container-terminal.*",
"node_modules",
"bower_components",
"scratch"
],
"main": [
"dist/container-terminal.js",
"dist/container-terminal.css"
],
"dependencies": {
"angular": ">=1.3.8 <1.5",
"term.js": "#0.0.3",
"font-awesome": "*"
},
"devDependencies": {
"patternfly": ">=1.2.1"
}
}
View
@@ -0,0 +1,49 @@
kubernetes-container-terminal {
position: relative;
display: block;
}
kubernetes-container-terminal .terminal {
font-family: monospace, courier new;
font-size: 10px;
color: #F0F0F0;
text-align: left;
outline: medium none;
background-color: black;
border: 1px solid black;
padding: 10px;
display: inline-block; /* size DIV to contents */
line-height: 1em;
}
@media (min-width: 568px) {
kubernetes-container-terminal .terminal {
font-size: 12px;
}
}
kubernetes-container-terminal .terminal-cursor {
color: #000;
background: #f0f0f0;
}
kubernetes-container-terminal .terminal-wrapper {
display: inline-block;
vertical-align: top;
}
kubernetes-container-terminal .terminal-actions {
display: inline-block;
vertical-align: top;
position: relative;
top: 10px;
right: 34px;
z-index: 1;
}
.spinner-white {
border-bottom: 4px solid rgba(255, 255, 255, 0.25);
border-left: 4px solid rgba(255, 255, 255, 0.25);
border-right: 4px solid rgba(255, 255, 255, 0.25);
border-top: 4px solid rgba(255, 255, 255, 0.75);
}
Oops, something went wrong.

0 comments on commit 9ac579d

Please sign in to comment.